[Forensics-changes] [yara] 141/192: Rename global variables to prevent naming conflicts

Hilko Bengen bengen at moszumanska.debian.org
Sat Jul 1 10:31:57 UTC 2017


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

bengen pushed a commit to annotated tag v3.6.0
in repository yara.

commit ce857f034869f3a8fa10e4f966978fcc94b44cb9
Author: Victor Manuel Alvarez <vmalvarez at vmalvarez-macbookpro.roam.corp.google.com>
Date:   Thu Apr 20 18:33:58 2017 +0200

    Rename global variables to prevent naming conflicts
---
 libyara/hex_lexer.c            | 225 ++++++++++++++++-------------------------
 libyara/hex_lexer.l            |   8 +-
 libyara/include/yara/globals.h |   9 +-
 libyara/libyara.c              |  28 ++---
 libyara/re.c                   |   4 +-
 libyara/re_lexer.c             | 190 +++++++++++++---------------------
 libyara/re_lexer.l             |   9 +-
 libyara/scan.c                 |   4 +-
 8 files changed, 185 insertions(+), 292 deletions(-)

diff --git a/libyara/hex_lexer.c b/libyara/hex_lexer.c
index 86ab9f4..52cfb19 100644
--- a/libyara/hex_lexer.c
+++ b/libyara/hex_lexer.c
@@ -8,8 +8,8 @@
 
 #define FLEX_SCANNER
 #define YY_FLEX_MAJOR_VERSION 2
-#define YY_FLEX_MINOR_VERSION 6
-#define YY_FLEX_SUBMINOR_VERSION 0
+#define YY_FLEX_MINOR_VERSION 5
+#define YY_FLEX_SUBMINOR_VERSION 35
 #if YY_FLEX_SUBMINOR_VERSION > 0
 #define FLEX_BETA
 #endif
@@ -47,6 +47,7 @@ typedef int16_t flex_int16_t;
 typedef uint16_t flex_uint16_t;
 typedef int32_t flex_int32_t;
 typedef uint32_t flex_uint32_t;
+typedef uint64_t flex_uint64_t;
 #else
 typedef signed char flex_int8_t;
 typedef short int flex_int16_t;
@@ -54,6 +55,7 @@ typedef int flex_int32_t;
 typedef unsigned char flex_uint8_t; 
 typedef unsigned short int flex_uint16_t;
 typedef unsigned int flex_uint32_t;
+#endif /* ! C99 */
 
 /* Limits of integral types. */
 #ifndef INT8_MIN
@@ -84,8 +86,6 @@ typedef unsigned int flex_uint32_t;
 #define UINT32_MAX             (4294967295U)
 #endif
 
-#endif /* ! C99 */
-
 #endif /* ! FLEXINT_H */
 
 #ifdef __cplusplus
@@ -159,15 +159,7 @@ typedef void* yyscan_t;
 
 /* Size of default input buffer. */
 #ifndef YY_BUF_SIZE
-#ifdef __ia64__
-/* On IA-64, the buffer size is 16k, not 8k.
- * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
- * Ditto for the __ia64__ case accordingly.
- */
-#define YY_BUF_SIZE 32768
-#else
 #define YY_BUF_SIZE 16384
-#endif /* __ia64__ */
 #endif
 
 /* The state buf must be large enough to hold one state per character in the main buffer.
@@ -197,18 +189,11 @@ typedef size_t yy_size_t;
      */
     #define  YY_LESS_LINENO(n) \
             do { \
-                int yyl;\
+                yy_size_t yyl;\
                 for ( yyl = n; yyl < yyleng; ++yyl )\
                     if ( yytext[yyl] == '\n' )\
                         --yylineno;\
             }while(0)
-    #define YY_LINENO_REWIND_TO(dst) \
-            do {\
-                const char *p;\
-                for ( p = yy_cp-1; p >= (dst); --p)\
-                    if ( *p == '\n' )\
-                        --yylineno;\
-            }while(0)
     
 /* Return all but the first "n" matched characters back to the input stream. */
 #define yyless(n) \
@@ -354,7 +339,7 @@ void hex_yyfree (void * ,yyscan_t yyscanner );
 
 /* Begin user sect3 */
 
-#define hex_yywrap(yyscanner) (/*CONSTCOND*/1)
+#define hex_yywrap(n) 1
 #define YY_SKIP_YYWRAP
 
 typedef unsigned char YY_CHAR;
@@ -366,9 +351,6 @@ typedef int yy_state_type;
 static yy_state_type yy_get_previous_state (yyscan_t yyscanner );
 static yy_state_type yy_try_NUL_trans (yy_state_type current_state  ,yyscan_t yyscanner);
 static int yy_get_next_buffer (yyscan_t yyscanner );
-#if defined(__GNUC__) && __GNUC__ >= 3
-__attribute__((__noreturn__))
-#endif
 static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
 
 /* Done after the current pattern has been matched and before the
@@ -376,7 +358,7 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
  */
 #define YY_DO_BEFORE_ACTION \
 	yyg->yytext_ptr = yy_bp; \
-	yyleng = (size_t) (yy_cp - yy_bp); \
+	yyleng = (yy_size_t) (yy_cp - yy_bp); \
 	yyg->yy_hold_char = *yy_cp; \
 	*yy_cp = '\0'; \
 	yyg->yy_c_buf_p = yy_cp;
@@ -398,7 +380,7 @@ static yyconst flex_int16_t yy_accept[35] =
         0,    7,    6,    0
     } ;
 
-static yyconst YY_CHAR yy_ec[256] =
+static yyconst flex_int32_t yy_ec[256] =
     {   0,
         1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
         1,    1,    2,    1,    1,    1,    1,    1,    1,    1,
@@ -430,13 +412,13 @@ static yyconst YY_CHAR yy_ec[256] =
         1,    1,    1,    1,    1
     } ;
 
-static yyconst YY_CHAR yy_meta[13] =
+static yyconst flex_int32_t yy_meta[13] =
     {   0,
         1,    1,    2,    1,    1,    1,    1,    3,    3,    3,
         1,    1
     } ;
 
-static yyconst flex_uint16_t yy_base[40] =
+static yyconst flex_int16_t yy_base[40] =
     {   0,
         0,    0,    0,    0,   12,    0,   46,   47,   47,   47,
        47,   20,   36,   35,   47,   47,   47,   47,   47,   47,
@@ -452,7 +434,7 @@ static yyconst flex_int16_t yy_def[40] =
        38,   39,   38,    0,   34,   34,   34,   34,   34
     } ;
 
-static yyconst flex_uint16_t yy_nxt[60] =
+static yyconst flex_int16_t yy_nxt[60] =
     {   0,
         8,    9,   10,   11,    8,    8,   12,   13,   14,   13,
        15,    8,   17,   18,   19,   17,   17,   20,   17,   21,
@@ -531,6 +513,7 @@ with noyywrap then we can remove this pragma.
 
 #include <setjmp.h>
 
+#include <yara/globals.h>
 #include <yara/limits.h>
 #include <yara/error.h>
 #include <yara/mem.h>
@@ -557,7 +540,7 @@ with noyywrap then we can remove this pragma.
 #define YY_NO_INPUT 1
 
 
-#line 561 "hex_lexer.c"
+#line 544 "hex_lexer.c"
 
 #define INITIAL 0
 #define comment 1
@@ -636,11 +619,11 @@ void hex_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
 
 FILE *hex_yyget_in (yyscan_t yyscanner );
 
-void hex_yyset_in  (FILE * _in_str ,yyscan_t yyscanner );
+void hex_yyset_in  (FILE * in_str ,yyscan_t yyscanner );
 
 FILE *hex_yyget_out (yyscan_t yyscanner );
 
-void hex_yyset_out  (FILE * _out_str ,yyscan_t yyscanner );
+void hex_yyset_out  (FILE * out_str ,yyscan_t yyscanner );
 
 yy_size_t hex_yyget_leng (yyscan_t yyscanner );
 
@@ -648,11 +631,7 @@ char *hex_yyget_text (yyscan_t yyscanner );
 
 int hex_yyget_lineno (yyscan_t yyscanner );
 
-void hex_yyset_lineno (int _line_number ,yyscan_t yyscanner );
-
-int hex_yyget_column  (yyscan_t yyscanner );
-
-void hex_yyset_column (int _column_no ,yyscan_t yyscanner );
+void hex_yyset_lineno (int line_number ,yyscan_t yyscanner );
 
 YYSTYPE * hex_yyget_lval (yyscan_t yyscanner );
 
@@ -670,10 +649,6 @@ extern int hex_yywrap (yyscan_t yyscanner );
 #endif
 #endif
 
-#ifndef YY_NO_UNPUT
-    
-#endif
-
 #ifndef yytext_ptr
 static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
 #endif
@@ -694,12 +669,7 @@ static int input (yyscan_t yyscanner );
 
 /* Amount of stuff to slurp up with each read. */
 #ifndef YY_READ_BUF_SIZE
-#ifdef __ia64__
-/* On IA-64, the buffer size is 16k, not 8k */
-#define YY_READ_BUF_SIZE 16384
-#else
 #define YY_READ_BUF_SIZE 8192
-#endif /* __ia64__ */
 #endif
 
 /* Copy whatever the last rule matched to the standard output. */
@@ -707,7 +677,7 @@ static int input (yyscan_t yyscanner );
 /* This used to be an fputs(), but since the string might contain NUL's,
  * we now use fwrite().
  */
-#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
+#define ECHO fwrite( yytext, yyleng, 1, yyout )
 #endif
 
 /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
@@ -718,7 +688,7 @@ static int input (yyscan_t yyscanner );
 	if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
 		{ \
 		int c = '*'; \
-		size_t n; \
+		yy_size_t n; \
 		for ( n = 0; n < max_size && \
 			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
 			buf[n] = (char) c; \
@@ -788,7 +758,7 @@ extern int hex_yylex \
 
 /* Code executed at the end of each rule. */
 #ifndef YY_BREAK
-#define YY_BREAK /*LINTED*/break;
+#define YY_BREAK break;
 #endif
 
 #define YY_RULE_SETUP \
@@ -798,11 +768,17 @@ extern int hex_yylex \
  */
 YY_DECL
 {
-	yy_state_type yy_current_state;
-	char *yy_cp, *yy_bp;
-	int yy_act;
+	register yy_state_type yy_current_state;
+	register char *yy_cp, *yy_bp;
+	register int yy_act;
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
+#line 95 "hex_lexer.l"
+
+
+
+#line 781 "hex_lexer.c"
+
     yylval = yylval_param;
 
 	if ( !yyg->yy_init )
@@ -831,14 +807,7 @@ YY_DECL
 		hex_yy_load_buffer_state(yyscanner );
 		}
 
-	{
-#line 94 "hex_lexer.l"
-
-
-
-#line 840 "hex_lexer.c"
-
-	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
+	while ( 1 )		/* loops until end-of-file is reached */
 		{
 		yy_cp = yyg->yy_c_buf_p;
 
@@ -854,7 +823,7 @@ YY_DECL
 yy_match:
 		do
 			{
-			YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
+			register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
 			if ( yy_accept[yy_current_state] )
 				{
 				yyg->yy_last_accepting_state = yy_current_state;
@@ -903,7 +872,7 @@ do_action:	/* This label is used only to access EOF actions. */
 
 case 1:
 YY_RULE_SETUP
-#line 97 "hex_lexer.l"
+#line 98 "hex_lexer.l"
 {
 
   yylval->integer = xtoi(yytext);
@@ -912,7 +881,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 2:
 YY_RULE_SETUP
-#line 103 "hex_lexer.l"
+#line 104 "hex_lexer.l"
 {
 
   yytext[1] = '0'; // replace ? by 0
@@ -922,7 +891,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 3:
 YY_RULE_SETUP
-#line 110 "hex_lexer.l"
+#line 111 "hex_lexer.l"
 {
 
   yytext[0] = '0'; // replace ? by 0
@@ -932,7 +901,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 4:
 YY_RULE_SETUP
-#line 117 "hex_lexer.l"
+#line 118 "hex_lexer.l"
 {
 
   yylval->integer = 0x0000;
@@ -941,7 +910,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 5:
 YY_RULE_SETUP
-#line 123 "hex_lexer.l"
+#line 124 "hex_lexer.l"
 {
 
   BEGIN(range);
@@ -951,24 +920,24 @@ YY_RULE_SETUP
 case 6:
 /* rule 6 can match eol */
 YY_RULE_SETUP
-#line 129 "hex_lexer.l"
+#line 130 "hex_lexer.l"
 // skip comments
 	YY_BREAK
 case 7:
 YY_RULE_SETUP
-#line 131 "hex_lexer.l"
+#line 132 "hex_lexer.l"
 // skip single-line comments
 	YY_BREAK
 case 8:
 YY_RULE_SETUP
-#line 133 "hex_lexer.l"
+#line 134 "hex_lexer.l"
 {
   return yytext[0];
 }
 	YY_BREAK
 case 9:
 YY_RULE_SETUP
-#line 137 "hex_lexer.l"
+#line 138 "hex_lexer.l"
 {
 
   yylval->integer = atoi(yytext);
@@ -977,7 +946,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 10:
 YY_RULE_SETUP
-#line 143 "hex_lexer.l"
+#line 144 "hex_lexer.l"
 {
 
   BEGIN(INITIAL);
@@ -987,12 +956,12 @@ YY_RULE_SETUP
 case 11:
 /* rule 11 can match eol */
 YY_RULE_SETUP
-#line 149 "hex_lexer.l"
+#line 150 "hex_lexer.l"
 // skip whitespaces
 	YY_BREAK
 case 12:
 YY_RULE_SETUP
-#line 151 "hex_lexer.l"
+#line 152 "hex_lexer.l"
 {
 
   yyerror(yyscanner, lex_env, "invalid character in hex string jump");
@@ -1002,12 +971,12 @@ YY_RULE_SETUP
 case 13:
 /* rule 13 can match eol */
 YY_RULE_SETUP
-#line 157 "hex_lexer.l"
+#line 158 "hex_lexer.l"
 // skip whitespaces
 	YY_BREAK
 case 14:
 YY_RULE_SETUP
-#line 159 "hex_lexer.l"
+#line 160 "hex_lexer.l"
 {        // pass valid characters to the parser
 
   return yytext[0];
@@ -1015,7 +984,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 15:
 YY_RULE_SETUP
-#line 164 "hex_lexer.l"
+#line 165 "hex_lexer.l"
 {               // reject all other characters
 
   yyerror(yyscanner, lex_env, "invalid character in hex string");
@@ -1024,10 +993,10 @@ YY_RULE_SETUP
 	YY_BREAK
 case 16:
 YY_RULE_SETUP
-#line 170 "hex_lexer.l"
+#line 171 "hex_lexer.l"
 ECHO;
 	YY_BREAK
-#line 1031 "hex_lexer.c"
+#line 1000 "hex_lexer.c"
 case YY_STATE_EOF(INITIAL):
 case YY_STATE_EOF(comment):
 case YY_STATE_EOF(range):
@@ -1161,7 +1130,6 @@ case YY_STATE_EOF(range):
 			"fatal flex scanner internal error--no action found" );
 	} /* end of action switch */
 		} /* end of scanning one token */
-	} /* end of user's declarations */
 } /* end of hex_yylex */
 
 /* yy_get_next_buffer - try to read in a new buffer
@@ -1174,9 +1142,9 @@ case YY_STATE_EOF(range):
 static int yy_get_next_buffer (yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-	char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
-	char *source = yyg->yytext_ptr;
-	yy_size_t number_to_move, i;
+	register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
+	register char *source = yyg->yytext_ptr;
+	register int number_to_move, i;
 	int ret_val;
 
 	if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
@@ -1205,7 +1173,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
 	/* Try to read more data. */
 
 	/* First move last chars to start of buffer. */
-	number_to_move = (yy_size_t) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
+	number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
 
 	for ( i = 0; i < number_to_move; ++i )
 		*(dest++) = *(source++);
@@ -1225,7 +1193,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
 			{ /* Not enough room in the buffer - grow it. */
 
 			/* just a shorter name for the current buffer */
-			YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
+			YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
 
 			int yy_c_buf_p_offset =
 				(int) (yyg->yy_c_buf_p - b->yy_ch_buf);
@@ -1308,15 +1276,15 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
 
     static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
 {
-	yy_state_type yy_current_state;
-	char *yy_cp;
+	register yy_state_type yy_current_state;
+	register char *yy_cp;
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
 	yy_current_state = yyg->yy_start;
 
 	for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
 		{
-		YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+		register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
 		if ( yy_accept[yy_current_state] )
 			{
 			yyg->yy_last_accepting_state = yy_current_state;
@@ -1341,11 +1309,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
  */
     static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state , yyscan_t yyscanner)
 {
-	int yy_is_jam;
+	register int yy_is_jam;
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
-	char *yy_cp = yyg->yy_c_buf_p;
+	register char *yy_cp = yyg->yy_c_buf_p;
 
-	YY_CHAR yy_c = 1;
+	register YY_CHAR yy_c = 1;
 	if ( yy_accept[yy_current_state] )
 		{
 		yyg->yy_last_accepting_state = yy_current_state;
@@ -1360,14 +1328,9 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
 	yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
 	yy_is_jam = (yy_current_state == 34);
 
-	(void)yyg;
 	return yy_is_jam ? 0 : yy_current_state;
 }
 
-#ifndef YY_NO_UNPUT
-
-#endif
-
 #ifndef YY_NO_INPUT
 #ifdef __cplusplus
     static int yyinput (yyscan_t yyscanner)
@@ -1417,7 +1380,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
 				case EOB_ACT_END_OF_FILE:
 					{
 					if ( hex_yywrap(yyscanner ) )
-						return EOF;
+						return 0;
 
 					if ( ! yyg->yy_did_buffer_switch_on_eof )
 						YY_NEW_FILE;
@@ -1528,7 +1491,7 @@ static void hex_yy_load_buffer_state  (yyscan_t yyscanner)
 	if ( ! b )
 		YY_FATAL_ERROR( "out of dynamic memory in hex_yy_create_buffer()" );
 
-	b->yy_buf_size = (yy_size_t)size;
+	b->yy_buf_size = size;
 
 	/* yy_ch_buf has to be 2 characters longer than the size given because
 	 * we need to put in 2 end-of-buffer characters.
@@ -1689,7 +1652,7 @@ static void hex_yyensure_buffer_stack (yyscan_t yyscanner)
 		 * scanner will even need a stack. We use 2 instead of 1 to avoid an
 		 * immediate realloc on the next call.
          */
-		num_to_alloc = 1; // After all that talk, this was set to 1 anyways...
+		num_to_alloc = 1;
 		yyg->yy_buffer_stack = (struct yy_buffer_state**)hex_yyalloc
 								(num_to_alloc * sizeof(struct yy_buffer_state*)
 								, yyscanner);
@@ -1706,7 +1669,7 @@ static void hex_yyensure_buffer_stack (yyscan_t yyscanner)
 	if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
 
 		/* Increase the buffer to prepare for a possible push. */
-		yy_size_t grow_size = 8 /* arbitrary grow size */;
+		int grow_size = 8 /* arbitrary grow size */;
 
 		num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
 		yyg->yy_buffer_stack = (struct yy_buffer_state**)hex_yyrealloc
@@ -1773,8 +1736,8 @@ YY_BUFFER_STATE hex_yy_scan_string (yyconst char * yystr , yyscan_t yyscanner)
 
 /** Setup the input buffer state to scan the given bytes. The next call to hex_yylex() will
  * scan from a @e copy of @a bytes.
- * @param yybytes the byte buffer to scan
- * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
+ * @param bytes the byte buffer to scan
+ * @param len the number of bytes in the buffer pointed to by @a bytes.
  * @param yyscanner The scanner object.
  * @return the newly allocated buffer state object.
  */
@@ -1782,8 +1745,7 @@ YY_BUFFER_STATE hex_yy_scan_bytes  (yyconst char * yybytes, yy_size_t  _yybytes_
 {
 	YY_BUFFER_STATE b;
 	char *buf;
-	yy_size_t n;
-	yy_size_t i;
+	yy_size_t n, i;
     
 	/* Get memory for full buffer, including space for trailing EOB's. */
 	n = _yybytes_len + 2;
@@ -1814,9 +1776,7 @@ YY_BUFFER_STATE hex_yy_scan_bytes  (yyconst char * yybytes, yy_size_t  _yybytes_
 
 static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
 {
-	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-	(void)yyg;
-	(void) fprintf( stderr, "%s\n", msg );
+    	(void) fprintf( stderr, "%s\n", msg );
 	exit( YY_EXIT_FAILURE );
 }
 
@@ -1922,51 +1882,51 @@ void hex_yyset_extra (YY_EXTRA_TYPE  user_defined , yyscan_t yyscanner)
 }
 
 /** Set the current line number.
- * @param _line_number line number
+ * @param line_number
  * @param yyscanner The scanner object.
  */
-void hex_yyset_lineno (int  _line_number , yyscan_t yyscanner)
+void hex_yyset_lineno (int  line_number , yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
         /* lineno is only valid if an input buffer exists. */
         if (! YY_CURRENT_BUFFER )
-           YY_FATAL_ERROR( "hex_yyset_lineno called with no buffer" );
+           yy_fatal_error( "hex_yyset_lineno called with no buffer" , yyscanner); 
     
-    yylineno = _line_number;
+    yylineno = line_number;
 }
 
 /** Set the current column.
- * @param _column_no column number
+ * @param line_number
  * @param yyscanner The scanner object.
  */
-void hex_yyset_column (int  _column_no , yyscan_t yyscanner)
+void hex_yyset_column (int  column_no , yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
         /* column is only valid if an input buffer exists. */
         if (! YY_CURRENT_BUFFER )
-           YY_FATAL_ERROR( "hex_yyset_column called with no buffer" );
+           yy_fatal_error( "hex_yyset_column called with no buffer" , yyscanner); 
     
-    yycolumn = _column_no;
+    yycolumn = column_no;
 }
 
 /** Set the input stream. This does not discard the current
  * input buffer.
- * @param _in_str A readable stream.
+ * @param in_str A readable stream.
  * @param yyscanner The scanner object.
  * @see hex_yy_switch_to_buffer
  */
-void hex_yyset_in (FILE *  _in_str , yyscan_t yyscanner)
+void hex_yyset_in (FILE *  in_str , yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-    yyin = _in_str ;
+    yyin = in_str ;
 }
 
-void hex_yyset_out (FILE *  _out_str , yyscan_t yyscanner)
+void hex_yyset_out (FILE *  out_str , yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-    yyout = _out_str ;
+    yyout = out_str ;
 }
 
 int hex_yyget_debug  (yyscan_t yyscanner)
@@ -1975,10 +1935,10 @@ int hex_yyget_debug  (yyscan_t yyscanner)
     return yy_flex_debug;
 }
 
-void hex_yyset_debug (int  _bdebug , yyscan_t yyscanner)
+void hex_yyset_debug (int  bdebug , yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-    yy_flex_debug = _bdebug ;
+    yy_flex_debug = bdebug ;
 }
 
 /* Accessor methods for yylval and yylloc */
@@ -2129,10 +2089,7 @@ int hex_yylex_destroy  (yyscan_t yyscanner)
 #ifndef yytext_ptr
 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
 {
-	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-	(void)yyg;
-
-	int i;
+	register int i;
 	for ( i = 0; i < n; ++i )
 		s1[i] = s2[i];
 }
@@ -2141,7 +2098,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yysca
 #ifdef YY_NEED_STRLEN
 static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
 {
-	int n;
+	register int n;
 	for ( n = 0; s[n]; ++n )
 		;
 
@@ -2151,16 +2108,11 @@ static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
 
 void *hex_yyalloc (yy_size_t  size , yyscan_t yyscanner)
 {
-	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-	(void)yyg;
 	return (void *) malloc( size );
 }
 
 void *hex_yyrealloc  (void * ptr, yy_size_t  size , yyscan_t yyscanner)
 {
-	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-	(void)yyg;
-
 	/* The cast to (char *) in the following accommodates both
 	 * implementations that use char* generic pointers, and those
 	 * that use void* generic pointers.  It works with the latter
@@ -2173,18 +2125,13 @@ void *hex_yyrealloc  (void * ptr, yy_size_t  size , yyscan_t yyscanner)
 
 void hex_yyfree (void * ptr , yyscan_t yyscanner)
 {
-	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-	(void)yyg;
 	free( (char *) ptr );	/* see hex_yyrealloc() for (char *) cast */
 }
 
 #define YYTABLES_NAME "yytables"
 
-#line 170 "hex_lexer.l"
-
-
+#line 171 "hex_lexer.l"
 
-extern YR_THREAD_STORAGE_KEY recovery_state_key;
 
 
 void yyfatal(
@@ -2192,7 +2139,7 @@ void yyfatal(
     const char *error_message)
 {
   jmp_buf* recovery_state = (jmp_buf*) yr_thread_storage_get_value(
-      &recovery_state_key);
+      &yr_recovery_state_key);
 
   longjmp(*recovery_state, 1);
 }
@@ -2232,7 +2179,7 @@ int yr_parse_hex_string(
   lex_env.inside_or = 0;
   lex_env.token_count = 0;
 
-  yr_thread_storage_set_value(&recovery_state_key, &recovery_state);
+  yr_thread_storage_set_value(&yr_recovery_state_key, &recovery_state);
 
   if (setjmp(recovery_state) != 0)
     return ERROR_INTERNAL_FATAL_ERROR;
diff --git a/libyara/hex_lexer.l b/libyara/hex_lexer.l
index 980d2bd..2e00eaf 100644
--- a/libyara/hex_lexer.l
+++ b/libyara/hex_lexer.l
@@ -46,6 +46,7 @@ with noyywrap then we can remove this pragma.
 
 #include <setjmp.h>
 
+#include <yara/globals.h>
 #include <yara/limits.h>
 #include <yara/error.h>
 #include <yara/mem.h>
@@ -169,15 +170,12 @@ hexdigit      [a-fA-F0-9]
 
 %%
 
-extern YR_THREAD_STORAGE_KEY recovery_state_key;
-
-
 void yyfatal(
     yyscan_t yyscanner,
     const char *error_message)
 {
   jmp_buf* recovery_state = (jmp_buf*) yr_thread_storage_get_value(
-      &recovery_state_key);
+      &yr_recovery_state_key);
 
   longjmp(*recovery_state, 1);
 }
@@ -217,7 +215,7 @@ int yr_parse_hex_string(
   lex_env.inside_or = 0;
   lex_env.token_count = 0;
 
-  yr_thread_storage_set_value(&recovery_state_key, &recovery_state);
+  yr_thread_storage_set_value(&yr_recovery_state_key, &recovery_state);
 
   if (setjmp(recovery_state) != 0)
     return ERROR_INTERNAL_FATAL_ERROR;
diff --git a/libyara/include/yara/globals.h b/libyara/include/yara/globals.h
index 764a96f..efe0671 100644
--- a/libyara/include/yara/globals.h
+++ b/libyara/include/yara/globals.h
@@ -30,7 +30,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #ifndef YR_GLOBALS_H
 #define YR_GLOBALS_H
 
-extern char lowercase[256];
-extern char altercase[256];
+#include <yara/threading.h>
+
+extern char yr_lowercase[256];
+extern char yr_altercase[256];
+
+extern YR_THREAD_STORAGE_KEY yr_tidx_key;
+extern YR_THREAD_STORAGE_KEY yr_recovery_state_key;
 
 #endif
diff --git a/libyara/libyara.c b/libyara/libyara.c
index 7600212..49e2d1e 100644
--- a/libyara/libyara.c
+++ b/libyara/libyara.c
@@ -48,8 +48,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #endif
 
 
-YR_THREAD_STORAGE_KEY tidx_key;
-YR_THREAD_STORAGE_KEY recovery_state_key;
+YR_THREAD_STORAGE_KEY yr_tidx_key;
+YR_THREAD_STORAGE_KEY yr_recovery_state_key;
 
 
 static int init_count = 0;
@@ -67,8 +67,8 @@ static struct yr_config_var
 } yr_cfgs[YR_CONFIG_MAX];
 
 
-char lowercase[256];
-char altercase[256];
+char yr_lowercase[256];
+char yr_altercase[256];
 
 
 #if defined HAVE_LIBCRYPTO && OPENSSL_VERSION_NUMBER < 0x10100000L
@@ -120,18 +120,18 @@ YR_API int yr_initialize(void)
   for (i = 0; i < 256; i++)
   {
     if (i >= 'a' && i <= 'z')
-      altercase[i] = i - 32;
+      yr_altercase[i] = i - 32;
     else if (i >= 'A' && i <= 'Z')
-      altercase[i] = i + 32;
+      yr_altercase[i] = i + 32;
     else
-      altercase[i] = i;
+      yr_altercase[i] = i;
 
-    lowercase[i] = tolower(i);
+    yr_lowercase[i] = tolower(i);
   }
 
   FAIL_ON_ERROR(yr_heap_alloc());
-  FAIL_ON_ERROR(yr_thread_storage_create(&tidx_key));
-  FAIL_ON_ERROR(yr_thread_storage_create(&recovery_state_key));
+  FAIL_ON_ERROR(yr_thread_storage_create(&yr_tidx_key));
+  FAIL_ON_ERROR(yr_thread_storage_create(&yr_recovery_state_key));
 
   #if defined HAVE_LIBCRYPTO && OPENSSL_VERSION_NUMBER < 0x10100000L
 
@@ -203,8 +203,8 @@ YR_API int yr_finalize(void)
 
   #endif
 
-  FAIL_ON_ERROR(yr_thread_storage_destroy(&tidx_key));
-  FAIL_ON_ERROR(yr_thread_storage_destroy(&recovery_state_key));
+  FAIL_ON_ERROR(yr_thread_storage_destroy(&yr_tidx_key));
+  FAIL_ON_ERROR(yr_thread_storage_destroy(&yr_recovery_state_key));
   FAIL_ON_ERROR(yr_re_finalize());
   FAIL_ON_ERROR(yr_modules_finalize());
   FAIL_ON_ERROR(yr_heap_free());
@@ -226,7 +226,7 @@ YR_API int yr_finalize(void)
 
 YR_API void yr_set_tidx(int tidx)
 {
-  yr_thread_storage_set_value(&tidx_key, (void*) (size_t) (tidx + 1));
+  yr_thread_storage_set_value(&yr_tidx_key, (void*) (size_t) (tidx + 1));
 }
 
 
@@ -242,7 +242,7 @@ YR_API void yr_set_tidx(int tidx)
 
 YR_API int yr_get_tidx(void)
 {
-  return (int) (size_t) yr_thread_storage_get_value(&tidx_key) - 1;
+  return (int) (size_t) yr_thread_storage_get_value(&yr_tidx_key) - 1;
 }
 
 
diff --git a/libyara/re.c b/libyara/re.c
index 3d7bf9c..8237506 100644
--- a/libyara/re.c
+++ b/libyara/re.c
@@ -1941,7 +1941,7 @@ int yr_re_exec(
         case RE_OPCODE_LITERAL:
           prolog;
           if (flags & RE_FLAGS_NO_CASE)
-            match = lowercase[*input] == lowercase[*(ip + 1)];
+            match = yr_lowercase[*input] == yr_lowercase[*(ip + 1)];
           else
             match = (*input == *(ip + 1));
           action = match ? ACTION_NONE : ACTION_KILL;
@@ -1966,7 +1966,7 @@ int yr_re_exec(
           prolog;
           match = CHAR_IN_CLASS(*input, ip + 1);
           if (!match && (flags & RE_FLAGS_NO_CASE))
-            match = CHAR_IN_CLASS(altercase[*input], ip + 1);
+            match = CHAR_IN_CLASS(yr_altercase[*input], ip + 1);
           action = match ? ACTION_NONE : ACTION_KILL;
           fiber->ip += 33;
           break;
diff --git a/libyara/re_lexer.c b/libyara/re_lexer.c
index 3d748bc..0314edb 100644
--- a/libyara/re_lexer.c
+++ b/libyara/re_lexer.c
@@ -8,8 +8,8 @@
 
 #define FLEX_SCANNER
 #define YY_FLEX_MAJOR_VERSION 2
-#define YY_FLEX_MINOR_VERSION 6
-#define YY_FLEX_SUBMINOR_VERSION 0
+#define YY_FLEX_MINOR_VERSION 5
+#define YY_FLEX_SUBMINOR_VERSION 35
 #if YY_FLEX_SUBMINOR_VERSION > 0
 #define FLEX_BETA
 #endif
@@ -47,6 +47,7 @@ typedef int16_t flex_int16_t;
 typedef uint16_t flex_uint16_t;
 typedef int32_t flex_int32_t;
 typedef uint32_t flex_uint32_t;
+typedef uint64_t flex_uint64_t;
 #else
 typedef signed char flex_int8_t;
 typedef short int flex_int16_t;
@@ -54,6 +55,7 @@ typedef int flex_int32_t;
 typedef unsigned char flex_uint8_t; 
 typedef unsigned short int flex_uint16_t;
 typedef unsigned int flex_uint32_t;
+#endif /* ! C99 */
 
 /* Limits of integral types. */
 #ifndef INT8_MIN
@@ -84,8 +86,6 @@ typedef unsigned int flex_uint32_t;
 #define UINT32_MAX             (4294967295U)
 #endif
 
-#endif /* ! C99 */
-
 #endif /* ! FLEXINT_H */
 
 #ifdef __cplusplus
@@ -159,15 +159,7 @@ typedef void* yyscan_t;
 
 /* Size of default input buffer. */
 #ifndef YY_BUF_SIZE
-#ifdef __ia64__
-/* On IA-64, the buffer size is 16k, not 8k.
- * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
- * Ditto for the __ia64__ case accordingly.
- */
-#define YY_BUF_SIZE 32768
-#else
 #define YY_BUF_SIZE 16384
-#endif /* __ia64__ */
 #endif
 
 /* The state buf must be large enough to hold one state per character in the main buffer.
@@ -197,18 +189,11 @@ typedef size_t yy_size_t;
      */
     #define  YY_LESS_LINENO(n) \
             do { \
-                int yyl;\
+                yy_size_t yyl;\
                 for ( yyl = n; yyl < yyleng; ++yyl )\
                     if ( yytext[yyl] == '\n' )\
                         --yylineno;\
             }while(0)
-    #define YY_LINENO_REWIND_TO(dst) \
-            do {\
-                const char *p;\
-                for ( p = yy_cp-1; p >= (dst); --p)\
-                    if ( *p == '\n' )\
-                        --yylineno;\
-            }while(0)
     
 /* Return all but the first "n" matched characters back to the input stream. */
 #define yyless(n) \
@@ -354,7 +339,7 @@ void re_yyfree (void * ,yyscan_t yyscanner );
 
 /* Begin user sect3 */
 
-#define re_yywrap(yyscanner) (/*CONSTCOND*/1)
+#define re_yywrap(n) 1
 #define YY_SKIP_YYWRAP
 
 typedef unsigned char YY_CHAR;
@@ -366,9 +351,6 @@ typedef int yy_state_type;
 static yy_state_type yy_get_previous_state (yyscan_t yyscanner );
 static yy_state_type yy_try_NUL_trans (yy_state_type current_state  ,yyscan_t yyscanner);
 static int yy_get_next_buffer (yyscan_t yyscanner );
-#if defined(__GNUC__) && __GNUC__ >= 3
-__attribute__((__noreturn__))
-#endif
 static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
 
 /* Done after the current pattern has been matched and before the
@@ -376,7 +358,7 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
  */
 #define YY_DO_BEFORE_ACTION \
 	yyg->yytext_ptr = yy_bp; \
-	yyleng = (size_t) (yy_cp - yy_bp); \
+	yyleng = (yy_size_t) (yy_cp - yy_bp); \
 	yyg->yy_hold_char = *yy_cp; \
 	*yy_cp = '\0'; \
 	yyg->yy_c_buf_p = yy_cp;
@@ -399,7 +381,7 @@ static yyconst flex_int16_t yy_accept[45] =
         2,   19,    0,    0
     } ;
 
-static yyconst YY_CHAR yy_ec[256] =
+static yyconst flex_int32_t yy_ec[256] =
     {   0,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    2,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
@@ -431,14 +413,14 @@ static yyconst YY_CHAR yy_ec[256] =
         1,    1,    1,    1,    1
     } ;
 
-static yyconst YY_CHAR yy_meta[23] =
+static yyconst flex_int32_t yy_meta[23] =
     {   0,
         1,    2,    1,    1,    3,    4,    4,    4,    4,    1,
         1,    1,    1,    5,    1,    4,    4,    1,    1,    1,
         1,    1
     } ;
 
-static yyconst flex_uint16_t yy_base[51] =
+static yyconst flex_int16_t yy_base[51] =
     {   0,
         0,   20,    3,    5,   50,   89,   89,   89,   10,   36,
         0,   44,   43,   47,   38,   89,   26,   33,   89,   89,
@@ -456,7 +438,7 @@ static yyconst flex_int16_t yy_def[51] =
        44,   44,   50,    0,   44,   44,   44,   44,   44,   44
     } ;
 
-static yyconst flex_uint16_t yy_nxt[112] =
+static yyconst flex_int16_t yy_nxt[112] =
     {   0,
        44,    7,    8,   27,   13,   28,   13,   30,   27,   39,
        28,    9,   10,   39,    8,   14,   15,   14,   15,   29,
@@ -551,7 +533,7 @@ with noyywrap then we can remove this pragma.
 #include <assert.h>
 #include <setjmp.h>
 
-
+#include <yara/globals.h>
 #include <yara/utils.h>
 #include <yara/error.h>
 #include <yara/limits.h>
@@ -582,7 +564,7 @@ int read_escaped_char(
 
 #define YY_NO_UNISTD_H 1
 
-#line 586 "re_lexer.c"
+#line 568 "re_lexer.c"
 
 #define INITIAL 0
 #define char_class 1
@@ -660,11 +642,11 @@ void re_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
 
 FILE *re_yyget_in (yyscan_t yyscanner );
 
-void re_yyset_in  (FILE * _in_str ,yyscan_t yyscanner );
+void re_yyset_in  (FILE * in_str ,yyscan_t yyscanner );
 
 FILE *re_yyget_out (yyscan_t yyscanner );
 
-void re_yyset_out  (FILE * _out_str ,yyscan_t yyscanner );
+void re_yyset_out  (FILE * out_str ,yyscan_t yyscanner );
 
 yy_size_t re_yyget_leng (yyscan_t yyscanner );
 
@@ -672,11 +654,7 @@ char *re_yyget_text (yyscan_t yyscanner );
 
 int re_yyget_lineno (yyscan_t yyscanner );
 
-void re_yyset_lineno (int _line_number ,yyscan_t yyscanner );
-
-int re_yyget_column  (yyscan_t yyscanner );
-
-void re_yyset_column (int _column_no ,yyscan_t yyscanner );
+void re_yyset_lineno (int line_number ,yyscan_t yyscanner );
 
 YYSTYPE * re_yyget_lval (yyscan_t yyscanner );
 
@@ -694,10 +672,6 @@ extern int re_yywrap (yyscan_t yyscanner );
 #endif
 #endif
 
-#ifndef YY_NO_UNPUT
-    
-#endif
-
 #ifndef yytext_ptr
 static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
 #endif
@@ -718,12 +692,7 @@ static int input (yyscan_t yyscanner );
 
 /* Amount of stuff to slurp up with each read. */
 #ifndef YY_READ_BUF_SIZE
-#ifdef __ia64__
-/* On IA-64, the buffer size is 16k, not 8k */
-#define YY_READ_BUF_SIZE 16384
-#else
 #define YY_READ_BUF_SIZE 8192
-#endif /* __ia64__ */
 #endif
 
 /* Copy whatever the last rule matched to the standard output. */
@@ -731,7 +700,7 @@ static int input (yyscan_t yyscanner );
 /* This used to be an fputs(), but since the string might contain NUL's,
  * we now use fwrite().
  */
-#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
+#define ECHO fwrite( yytext, yyleng, 1, yyout )
 #endif
 
 /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
@@ -742,7 +711,7 @@ static int input (yyscan_t yyscanner );
 	if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
 		{ \
 		int c = '*'; \
-		size_t n; \
+		yy_size_t n; \
 		for ( n = 0; n < max_size && \
 			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
 			buf[n] = (char) c; \
@@ -812,7 +781,7 @@ extern int re_yylex \
 
 /* Code executed at the end of each rule. */
 #ifndef YY_BREAK
-#define YY_BREAK /*LINTED*/break;
+#define YY_BREAK break;
 #endif
 
 #define YY_RULE_SETUP \
@@ -822,11 +791,16 @@ extern int re_yylex \
  */
 YY_DECL
 {
-	yy_state_type yy_current_state;
-	char *yy_cp, *yy_bp;
-	int yy_act;
+	register yy_state_type yy_current_state;
+	register char *yy_cp, *yy_bp;
+	register int yy_act;
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
+#line 99 "re_lexer.l"
+
+
+#line 803 "re_lexer.c"
+
     yylval = yylval_param;
 
 	if ( !yyg->yy_init )
@@ -855,13 +829,7 @@ YY_DECL
 		re_yy_load_buffer_state(yyscanner );
 		}
 
-	{
-#line 99 "re_lexer.l"
-
-
-#line 863 "re_lexer.c"
-
-	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
+	while ( 1 )		/* loops until end-of-file is reached */
 		{
 		yy_cp = yyg->yy_c_buf_p;
 
@@ -877,7 +845,7 @@ YY_DECL
 yy_match:
 		do
 			{
-			YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
+			register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
 			if ( yy_accept[yy_current_state] )
 				{
 				yyg->yy_last_accepting_state = yy_current_state;
@@ -1354,7 +1322,7 @@ YY_RULE_SETUP
 #line 464 "re_lexer.l"
 ECHO;
 	YY_BREAK
-#line 1358 "re_lexer.c"
+#line 1326 "re_lexer.c"
 
 	case YY_END_OF_BUFFER:
 		{
@@ -1484,7 +1452,6 @@ ECHO;
 			"fatal flex scanner internal error--no action found" );
 	} /* end of action switch */
 		} /* end of scanning one token */
-	} /* end of user's declarations */
 } /* end of re_yylex */
 
 /* yy_get_next_buffer - try to read in a new buffer
@@ -1497,9 +1464,9 @@ ECHO;
 static int yy_get_next_buffer (yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-	char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
-	char *source = yyg->yytext_ptr;
-	yy_size_t number_to_move, i;
+	register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
+	register char *source = yyg->yytext_ptr;
+	register int number_to_move, i;
 	int ret_val;
 
 	if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
@@ -1528,7 +1495,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
 	/* Try to read more data. */
 
 	/* First move last chars to start of buffer. */
-	number_to_move = (yy_size_t) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
+	number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
 
 	for ( i = 0; i < number_to_move; ++i )
 		*(dest++) = *(source++);
@@ -1548,7 +1515,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
 			{ /* Not enough room in the buffer - grow it. */
 
 			/* just a shorter name for the current buffer */
-			YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
+			YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
 
 			int yy_c_buf_p_offset =
 				(int) (yyg->yy_c_buf_p - b->yy_ch_buf);
@@ -1631,15 +1598,15 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
 
     static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
 {
-	yy_state_type yy_current_state;
-	char *yy_cp;
+	register yy_state_type yy_current_state;
+	register char *yy_cp;
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
 	yy_current_state = yyg->yy_start;
 
 	for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
 		{
-		YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+		register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
 		if ( yy_accept[yy_current_state] )
 			{
 			yyg->yy_last_accepting_state = yy_current_state;
@@ -1664,11 +1631,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
  */
     static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state , yyscan_t yyscanner)
 {
-	int yy_is_jam;
+	register int yy_is_jam;
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
-	char *yy_cp = yyg->yy_c_buf_p;
+	register char *yy_cp = yyg->yy_c_buf_p;
 
-	YY_CHAR yy_c = 1;
+	register YY_CHAR yy_c = 1;
 	if ( yy_accept[yy_current_state] )
 		{
 		yyg->yy_last_accepting_state = yy_current_state;
@@ -1683,14 +1650,9 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
 	yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
 	yy_is_jam = (yy_current_state == 44);
 
-	(void)yyg;
 	return yy_is_jam ? 0 : yy_current_state;
 }
 
-#ifndef YY_NO_UNPUT
-
-#endif
-
 #ifndef YY_NO_INPUT
 #ifdef __cplusplus
     static int yyinput (yyscan_t yyscanner)
@@ -1740,7 +1702,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
 				case EOB_ACT_END_OF_FILE:
 					{
 					if ( re_yywrap(yyscanner ) )
-						return EOF;
+						return 0;
 
 					if ( ! yyg->yy_did_buffer_switch_on_eof )
 						YY_NEW_FILE;
@@ -1851,7 +1813,7 @@ static void re_yy_load_buffer_state  (yyscan_t yyscanner)
 	if ( ! b )
 		YY_FATAL_ERROR( "out of dynamic memory in re_yy_create_buffer()" );
 
-	b->yy_buf_size = (yy_size_t)size;
+	b->yy_buf_size = size;
 
 	/* yy_ch_buf has to be 2 characters longer than the size given because
 	 * we need to put in 2 end-of-buffer characters.
@@ -2012,7 +1974,7 @@ static void re_yyensure_buffer_stack (yyscan_t yyscanner)
 		 * scanner will even need a stack. We use 2 instead of 1 to avoid an
 		 * immediate realloc on the next call.
          */
-		num_to_alloc = 1; // After all that talk, this was set to 1 anyways...
+		num_to_alloc = 1;
 		yyg->yy_buffer_stack = (struct yy_buffer_state**)re_yyalloc
 								(num_to_alloc * sizeof(struct yy_buffer_state*)
 								, yyscanner);
@@ -2029,7 +1991,7 @@ static void re_yyensure_buffer_stack (yyscan_t yyscanner)
 	if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
 
 		/* Increase the buffer to prepare for a possible push. */
-		yy_size_t grow_size = 8 /* arbitrary grow size */;
+		int grow_size = 8 /* arbitrary grow size */;
 
 		num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
 		yyg->yy_buffer_stack = (struct yy_buffer_state**)re_yyrealloc
@@ -2096,8 +2058,8 @@ YY_BUFFER_STATE re_yy_scan_string (yyconst char * yystr , yyscan_t yyscanner)
 
 /** Setup the input buffer state to scan the given bytes. The next call to re_yylex() will
  * scan from a @e copy of @a bytes.
- * @param yybytes the byte buffer to scan
- * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
+ * @param bytes the byte buffer to scan
+ * @param len the number of bytes in the buffer pointed to by @a bytes.
  * @param yyscanner The scanner object.
  * @return the newly allocated buffer state object.
  */
@@ -2105,8 +2067,7 @@ YY_BUFFER_STATE re_yy_scan_bytes  (yyconst char * yybytes, yy_size_t  _yybytes_l
 {
 	YY_BUFFER_STATE b;
 	char *buf;
-	yy_size_t n;
-	yy_size_t i;
+	yy_size_t n, i;
     
 	/* Get memory for full buffer, including space for trailing EOB's. */
 	n = _yybytes_len + 2;
@@ -2137,9 +2098,7 @@ YY_BUFFER_STATE re_yy_scan_bytes  (yyconst char * yybytes, yy_size_t  _yybytes_l
 
 static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
 {
-	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-	(void)yyg;
-	(void) fprintf( stderr, "%s\n", msg );
+    	(void) fprintf( stderr, "%s\n", msg );
 	exit( YY_EXIT_FAILURE );
 }
 
@@ -2245,51 +2204,51 @@ void re_yyset_extra (YY_EXTRA_TYPE  user_defined , yyscan_t yyscanner)
 }
 
 /** Set the current line number.
- * @param _line_number line number
+ * @param line_number
  * @param yyscanner The scanner object.
  */
-void re_yyset_lineno (int  _line_number , yyscan_t yyscanner)
+void re_yyset_lineno (int  line_number , yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
         /* lineno is only valid if an input buffer exists. */
         if (! YY_CURRENT_BUFFER )
-           YY_FATAL_ERROR( "re_yyset_lineno called with no buffer" );
+           yy_fatal_error( "re_yyset_lineno called with no buffer" , yyscanner); 
     
-    yylineno = _line_number;
+    yylineno = line_number;
 }
 
 /** Set the current column.
- * @param _column_no column number
+ * @param line_number
  * @param yyscanner The scanner object.
  */
-void re_yyset_column (int  _column_no , yyscan_t yyscanner)
+void re_yyset_column (int  column_no , yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
         /* column is only valid if an input buffer exists. */
         if (! YY_CURRENT_BUFFER )
-           YY_FATAL_ERROR( "re_yyset_column called with no buffer" );
+           yy_fatal_error( "re_yyset_column called with no buffer" , yyscanner); 
     
-    yycolumn = _column_no;
+    yycolumn = column_no;
 }
 
 /** Set the input stream. This does not discard the current
  * input buffer.
- * @param _in_str A readable stream.
+ * @param in_str A readable stream.
  * @param yyscanner The scanner object.
  * @see re_yy_switch_to_buffer
  */
-void re_yyset_in (FILE *  _in_str , yyscan_t yyscanner)
+void re_yyset_in (FILE *  in_str , yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-    yyin = _in_str ;
+    yyin = in_str ;
 }
 
-void re_yyset_out (FILE *  _out_str , yyscan_t yyscanner)
+void re_yyset_out (FILE *  out_str , yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-    yyout = _out_str ;
+    yyout = out_str ;
 }
 
 int re_yyget_debug  (yyscan_t yyscanner)
@@ -2298,10 +2257,10 @@ int re_yyget_debug  (yyscan_t yyscanner)
     return yy_flex_debug;
 }
 
-void re_yyset_debug (int  _bdebug , yyscan_t yyscanner)
+void re_yyset_debug (int  bdebug , yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-    yy_flex_debug = _bdebug ;
+    yy_flex_debug = bdebug ;
 }
 
 /* Accessor methods for yylval and yylloc */
@@ -2452,10 +2411,7 @@ int re_yylex_destroy  (yyscan_t yyscanner)
 #ifndef yytext_ptr
 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
 {
-	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-	(void)yyg;
-
-	int i;
+	register int i;
 	for ( i = 0; i < n; ++i )
 		s1[i] = s2[i];
 }
@@ -2464,7 +2420,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yysca
 #ifdef YY_NEED_STRLEN
 static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
 {
-	int n;
+	register int n;
 	for ( n = 0; s[n]; ++n )
 		;
 
@@ -2474,16 +2430,11 @@ static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
 
 void *re_yyalloc (yy_size_t  size , yyscan_t yyscanner)
 {
-	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-	(void)yyg;
 	return (void *) malloc( size );
 }
 
 void *re_yyrealloc  (void * ptr, yy_size_t  size , yyscan_t yyscanner)
 {
-	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-	(void)yyg;
-
 	/* The cast to (char *) in the following accommodates both
 	 * implementations that use char* generic pointers, and those
 	 * that use void* generic pointers.  It works with the latter
@@ -2496,8 +2447,6 @@ void *re_yyrealloc  (void * ptr, yy_size_t  size , yyscan_t yyscanner)
 
 void re_yyfree (void * ptr , yyscan_t yyscanner)
 {
-	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-	(void)yyg;
 	free( (char *) ptr );	/* see re_yyrealloc() for (char *) cast */
 }
 
@@ -2590,15 +2539,12 @@ int read_escaped_char(
 }
 
 
-extern YR_THREAD_STORAGE_KEY recovery_state_key;
-
-
 void yyfatal(
     yyscan_t yyscanner,
     const char *error_message)
 {
   jmp_buf* recovery_state = (jmp_buf*) yr_thread_storage_get_value(
-      &recovery_state_key);
+      &yr_recovery_state_key);
 
   longjmp(*recovery_state, 1);
 }
@@ -2637,7 +2583,7 @@ int yr_parse_re_string(
 
   lex_env.last_error_code = ERROR_SUCCESS;
 
-  yr_thread_storage_set_value(&recovery_state_key, &recovery_state);
+  yr_thread_storage_set_value(&yr_recovery_state_key, &recovery_state);
 
   if (setjmp(recovery_state) != 0)
     return ERROR_INTERNAL_FATAL_ERROR;
diff --git a/libyara/re_lexer.l b/libyara/re_lexer.l
index e9a4617..0f699ed 100644
--- a/libyara/re_lexer.l
+++ b/libyara/re_lexer.l
@@ -47,7 +47,7 @@ with noyywrap then we can remove this pragma.
 #include <assert.h>
 #include <setjmp.h>
 
-
+#include <yara/globals.h>
 #include <yara/utils.h>
 #include <yara/error.h>
 #include <yara/limits.h>
@@ -546,15 +546,12 @@ int read_escaped_char(
 }
 
 
-extern YR_THREAD_STORAGE_KEY recovery_state_key;
-
-
 void yyfatal(
     yyscan_t yyscanner,
     const char *error_message)
 {
   jmp_buf* recovery_state = (jmp_buf*) yr_thread_storage_get_value(
-      &recovery_state_key);
+      &yr_recovery_state_key);
 
   longjmp(*recovery_state, 1);
 }
@@ -593,7 +590,7 @@ int yr_parse_re_string(
 
   lex_env.last_error_code = ERROR_SUCCESS;
 
-  yr_thread_storage_set_value(&recovery_state_key, &recovery_state);
+  yr_thread_storage_set_value(&yr_recovery_state_key, &recovery_state);
 
   if (setjmp(recovery_state) != 0)
     return ERROR_INTERNAL_FATAL_ERROR;
diff --git a/libyara/scan.c b/libyara/scan.c
index 91b061e..93fcf8d 100644
--- a/libyara/scan.c
+++ b/libyara/scan.c
@@ -91,7 +91,7 @@ int _yr_scan_icompare(
   if (data_size < string_length)
     return 0;
 
-  while (i < string_length && lowercase[*s1++] == lowercase[*s2++])
+  while (i < string_length && yr_lowercase[*s1++] == yr_lowercase[*s2++])
     i++;
 
   return (int) ((i == string_length) ? i : 0);
@@ -137,7 +137,7 @@ int _yr_scan_wicompare(
   if (data_size < string_length * 2)
     return 0;
 
-  while (i < string_length && lowercase[*s1] == lowercase[*s2])
+  while (i < string_length && yr_lowercase[*s1] == yr_lowercase[*s2])
   {
     s1+=2;
     s2++;

-- 
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