[Forensics-changes] [yara] 05/407: Fix issue #165 by reorganizing header files

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


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

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

commit 80b340b4cd385528b157f6eff36512ba8a37d694
Author: Victor Manuel Alvarez <vmalvarez at virustotal.com>
Date:   Wed Aug 27 22:34:17 2014 +0200

    Fix issue #165 by reorganizing header files
---
 libyara/Makefile.am                          |   3 +-
 libyara/compiler.c                           |   1 +
 libyara/exec.c                               |   1 +
 libyara/hex_lexer.c                          |  11 +-
 libyara/hex_lexer.l                          |   2 +-
 libyara/include/yara/error.h                 |  13 +++
 libyara/include/yara/object.h                |   2 +-
 libyara/include/yara/{utils.h => strutils.h} |  43 +------
 libyara/include/yara/utils.h                 |  31 ++---
 libyara/lexer.c                              | 162 +++++++++++++--------------
 libyara/lexer.l                              |   3 +-
 libyara/{utils.c => strutils.c}              |  17 ++-
 12 files changed, 127 insertions(+), 162 deletions(-)

diff --git a/libyara/Makefile.am b/libyara/Makefile.am
index 67c07d0..33dec92 100644
--- a/libyara/Makefile.am
+++ b/libyara/Makefile.am
@@ -43,6 +43,7 @@ yarainclude_HEADERS = \
   include/yara/compiler.h \
   include/yara/modules.h \
   include/yara/object.h \
+  include/yara/strings.h \
   include/yara/libyara.h
 
 lib_LTLIBRARIES = libyara.la
@@ -88,7 +89,7 @@ libyara_la_SOURCES = \
   rules.c \
   scan.c \
   sizedstr.h \
-  utils.c \
+  strutils.c \
   utils.h
 
 
diff --git a/libyara/compiler.c b/libyara/compiler.c
index 77c752e..7c0de83 100644
--- a/libyara/compiler.c
+++ b/libyara/compiler.c
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */
 
+#include <assert.h>
 #include <stddef.h>
 #include <stdio.h>
 #include <string.h>
diff --git a/libyara/exec.c b/libyara/exec.c
index a2830c5..88f5c19 100644
--- a/libyara/exec.c
+++ b/libyara/exec.c
@@ -24,6 +24,7 @@ limitations under the License.
 #include <yara/object.h>
 #include <yara/modules.h>
 #include <yara/re.h>
+#include <yara/utils.h>
 
 
 #include <yara.h>
diff --git a/libyara/hex_lexer.c b/libyara/hex_lexer.c
index ed91564..9e1767e 100644
--- a/libyara/hex_lexer.c
+++ b/libyara/hex_lexer.c
@@ -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;
@@ -357,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;
@@ -483,7 +484,7 @@ limitations under the License.
 #include <yara/error.h>
 #include <yara/mem.h>
 #include <yara/re.h>
-#include <yara/utils.h>
+#include <yara/strings.h>
 #include <yara/hex_lexer.h>
 
 #include "hex_grammar.h"
@@ -503,7 +504,7 @@ limitations under the License.
 #define YY_NO_UNISTD_H 1
 #define YY_NO_INPUT 1
 
-#line 507 "hex_lexer.c"
+#line 508 "hex_lexer.c"
 
 #define INITIAL 0
 #define range 1
@@ -739,7 +740,7 @@ YY_DECL
 
 
 
-#line 743 "hex_lexer.c"
+#line 744 "hex_lexer.c"
 
     yylval = yylval_param;
 
@@ -942,7 +943,7 @@ YY_RULE_SETUP
 #line 138 "hex_lexer.l"
 ECHO;
 	YY_BREAK
-#line 946 "hex_lexer.c"
+#line 947 "hex_lexer.c"
 case YY_STATE_EOF(INITIAL):
 case YY_STATE_EOF(range):
 	yyterminate();
diff --git a/libyara/hex_lexer.l b/libyara/hex_lexer.l
index 17cea91..3a9531f 100644
--- a/libyara/hex_lexer.l
+++ b/libyara/hex_lexer.l
@@ -25,7 +25,7 @@ limitations under the License.
 #include <yara/error.h>
 #include <yara/mem.h>
 #include <yara/re.h>
-#include <yara/utils.h>
+#include <yara/strings.h>
 #include <yara/hex_lexer.h>
 
 #include "hex_grammar.h"
diff --git a/libyara/include/yara/error.h b/libyara/include/yara/error.h
index bf60da5..78261cd 100644
--- a/libyara/include/yara/error.h
+++ b/libyara/include/yara/error.h
@@ -17,6 +17,8 @@ limitations under the License.
 #ifndef YR_ERROR_H
 #define YR_ERROR_H
 
+#include <string.h>
+
 #ifndef ERROR_SUCCESS
 #define ERROR_SUCCESS                           0
 #endif
@@ -82,4 +84,15 @@ limitations under the License.
     return compiler->last_result; \
 }
 
+
+#ifdef NDEBUG
+#define assertf(expr, msg)  ((void)0)
+#else
+#define assertf(expr, msg, ...) \
+    if(!(expr)) { \
+      fprintf(stderr, "%s:%d: " msg "\n", __FILE__, __LINE__, ##__VA_ARGS__); \
+      abort(); \
+    }
+#endif
+
 #endif
diff --git a/libyara/include/yara/object.h b/libyara/include/yara/object.h
index 5eb5448..bd09dd4 100644
--- a/libyara/include/yara/object.h
+++ b/libyara/include/yara/object.h
@@ -17,7 +17,7 @@ limitations under the License.
 #ifndef YR_OBJECT_H
 #define YR_OBJECT_H
 
-#include <yara/rules.h>
+#include <yara/types.h>
 
 
 #define OBJECT_CREATE           1
diff --git a/libyara/include/yara/utils.h b/libyara/include/yara/strutils.h
similarity index 59%
copy from libyara/include/yara/utils.h
copy to libyara/include/yara/strutils.h
index c5fc7aa..6fc8b0e 100644
--- a/libyara/include/yara/utils.h
+++ b/libyara/include/yara/strutils.h
@@ -14,57 +14,22 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */
 
-#ifndef YR_UTILS_H
-#define YR_UTILS_H
+#ifndef YR_STRUTILS_H
+#define YR_STRUTILS_H
 
 #include <assert.h>
 #include <stdlib.h>
+#include <stdint.h>
 
 #include "config.h"
 
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-
-#ifndef min
-#define min(x, y) ((x < y) ? (x) : (y))
-#endif
-
-#ifndef max
-#define max(x, y) ((x > y) ? (x) : (y))
-#endif
-
-#define UINT64_TO_PTR(type, x)  ((type)(size_t) x)
-
-#define PTR_TO_UINT64(x)  ((uint64_t) (size_t) x)
-
 #ifdef _WIN32
 #define snprintf _snprintf
 #define strcasecmp _stricmp
 #define strncasecmp _strnicmp
 #endif
 
-
-#ifdef NDEBUG
-#define assertf(expr, msg)  ((void)0)
-#else
-#define assertf(expr, msg, ...) \
-    if(!(expr)) { \
-      fprintf(stderr, "%s:%d: " msg "\n", __FILE__, __LINE__, ##__VA_ARGS__); \
-      abort(); \
-    }
-#endif
-
-size_t xtoi(const char* hexstr);
+uint64_t xtoi(const char* hexstr);
 
 #if !HAVE_STRLCPY
 size_t strlcpy(char *dst, const char *src, size_t size);
diff --git a/libyara/include/yara/utils.h b/libyara/include/yara/utils.h
index c5fc7aa..1534a45 100644
--- a/libyara/include/yara/utils.h
+++ b/libyara/include/yara/utils.h
@@ -1,5 +1,5 @@
 /*
-Copyright (c) 2007. The YARA Authors. All Rights Reserved.
+Copyright (c) 2014. The YARA Authors. All Rights Reserved.
 
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
@@ -14,14 +14,10 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */
 
+
 #ifndef YR_UTILS_H
 #define YR_UTILS_H
 
-#include <assert.h>
-#include <stdlib.h>
-
-#include "config.h"
-
 #ifndef TRUE
 #define TRUE 1
 #endif
@@ -43,37 +39,26 @@ limitations under the License.
 #define max(x, y) ((x > y) ? (x) : (y))
 #endif
 
+
 #define UINT64_TO_PTR(type, x)  ((type)(size_t) x)
 
 #define PTR_TO_UINT64(x)  ((uint64_t) (size_t) x)
 
-#ifdef _WIN32
-#define snprintf _snprintf
-#define strcasecmp _stricmp
-#define strncasecmp _strnicmp
-#endif
-
 
 #ifdef NDEBUG
+
 #define assertf(expr, msg)  ((void)0)
+
 #else
+
+#include <stdlib.h>
+
 #define assertf(expr, msg, ...) \
     if(!(expr)) { \
       fprintf(stderr, "%s:%d: " msg "\n", __FILE__, __LINE__, ##__VA_ARGS__); \
       abort(); \
     }
-#endif
-
-size_t xtoi(const char* hexstr);
 
-#if !HAVE_STRLCPY
-size_t strlcpy(char *dst, const char *src, size_t size);
 #endif
 
-#if !HAVE_STRLCAT
-size_t strlcat(char *dst, const char *src, size_t size);
 #endif
-
-#endif
-
-
diff --git a/libyara/lexer.c b/libyara/lexer.c
index 8d114c8..e5598c7 100644
--- a/libyara/lexer.c
+++ b/libyara/lexer.c
@@ -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;
@@ -357,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;
@@ -643,11 +644,10 @@ limitations under the License.
 
 
 #include <yara/lexer.h>
-#include <yara/rules.h>
 #include <yara/sizedstr.h>
 #include <yara/error.h>
 #include <yara/mem.h>
-#include <yara/utils.h>
+#include <yara/strings.h>
 
 #include "grammar.h"
 
@@ -915,7 +915,7 @@ YY_DECL
 	register int yy_act;
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
-#line 83 "lexer.l"
+#line 82 "lexer.l"
 
 
 #line 922 "lexer.c"
@@ -1017,233 +1017,233 @@ do_action:	/* This label is used only to access EOF actions. */
 
 case 1:
 YY_RULE_SETUP
-#line 85 "lexer.l"
+#line 84 "lexer.l"
 { return _LT_;          }
 	YY_BREAK
 case 2:
 YY_RULE_SETUP
-#line 86 "lexer.l"
+#line 85 "lexer.l"
 { return _GT_;          }
 	YY_BREAK
 case 3:
 YY_RULE_SETUP
-#line 87 "lexer.l"
+#line 86 "lexer.l"
 { return _LE_;          }
 	YY_BREAK
 case 4:
 YY_RULE_SETUP
-#line 88 "lexer.l"
+#line 87 "lexer.l"
 { return _GE_;          }
 	YY_BREAK
 case 5:
 YY_RULE_SETUP
-#line 89 "lexer.l"
+#line 88 "lexer.l"
 { return _EQ_;          }
 	YY_BREAK
 case 6:
 YY_RULE_SETUP
-#line 90 "lexer.l"
+#line 89 "lexer.l"
 { return _NEQ_;         }
 	YY_BREAK
 case 7:
 YY_RULE_SETUP
-#line 91 "lexer.l"
+#line 90 "lexer.l"
 { return _SHIFT_LEFT_;  }
 	YY_BREAK
 case 8:
 YY_RULE_SETUP
-#line 92 "lexer.l"
+#line 91 "lexer.l"
 { return _SHIFT_RIGHT_; }
 	YY_BREAK
 case 9:
 YY_RULE_SETUP
-#line 93 "lexer.l"
+#line 92 "lexer.l"
 { return _PRIVATE_;     }
 	YY_BREAK
 case 10:
 YY_RULE_SETUP
-#line 94 "lexer.l"
+#line 93 "lexer.l"
 { return _GLOBAL_;      }
 	YY_BREAK
 case 11:
 YY_RULE_SETUP
-#line 95 "lexer.l"
+#line 94 "lexer.l"
 { return _RULE_;        }
 	YY_BREAK
 case 12:
 YY_RULE_SETUP
-#line 96 "lexer.l"
+#line 95 "lexer.l"
 { return _META_;        }
 	YY_BREAK
 case 13:
 YY_RULE_SETUP
-#line 97 "lexer.l"
+#line 96 "lexer.l"
 { return _STRINGS_;     }
 	YY_BREAK
 case 14:
 YY_RULE_SETUP
-#line 98 "lexer.l"
+#line 97 "lexer.l"
 { return _ASCII_;       }
 	YY_BREAK
 case 15:
 YY_RULE_SETUP
-#line 99 "lexer.l"
+#line 98 "lexer.l"
 { return _WIDE_;        }
 	YY_BREAK
 case 16:
 YY_RULE_SETUP
-#line 100 "lexer.l"
+#line 99 "lexer.l"
 { return _FULLWORD_;    }
 	YY_BREAK
 case 17:
 YY_RULE_SETUP
-#line 101 "lexer.l"
+#line 100 "lexer.l"
 { return _NOCASE_;      }
 	YY_BREAK
 case 18:
 YY_RULE_SETUP
-#line 102 "lexer.l"
+#line 101 "lexer.l"
 { return _CONDITION_;   }
 	YY_BREAK
 case 19:
 YY_RULE_SETUP
-#line 103 "lexer.l"
+#line 102 "lexer.l"
 { return _TRUE_;        }
 	YY_BREAK
 case 20:
 YY_RULE_SETUP
-#line 104 "lexer.l"
+#line 103 "lexer.l"
 { return _FALSE_;       }
 	YY_BREAK
 case 21:
 YY_RULE_SETUP
-#line 105 "lexer.l"
+#line 104 "lexer.l"
 { return _NOT_;         }
 	YY_BREAK
 case 22:
 YY_RULE_SETUP
-#line 106 "lexer.l"
+#line 105 "lexer.l"
 { return _AND_;         }
 	YY_BREAK
 case 23:
 YY_RULE_SETUP
-#line 107 "lexer.l"
+#line 106 "lexer.l"
 { return _OR_;          }
 	YY_BREAK
 case 24:
 YY_RULE_SETUP
-#line 108 "lexer.l"
+#line 107 "lexer.l"
 { return _AT_;          }
 	YY_BREAK
 case 25:
 YY_RULE_SETUP
-#line 109 "lexer.l"
+#line 108 "lexer.l"
 { return _IN_;          }
 	YY_BREAK
 case 26:
 YY_RULE_SETUP
-#line 110 "lexer.l"
+#line 109 "lexer.l"
 { return _OF_;          }
 	YY_BREAK
 case 27:
 YY_RULE_SETUP
-#line 111 "lexer.l"
+#line 110 "lexer.l"
 { return _THEM_;        }
 	YY_BREAK
 case 28:
 YY_RULE_SETUP
-#line 112 "lexer.l"
+#line 111 "lexer.l"
 { return _FOR_;         }
 	YY_BREAK
 case 29:
 YY_RULE_SETUP
-#line 113 "lexer.l"
+#line 112 "lexer.l"
 { return _ALL_;         }
 	YY_BREAK
 case 30:
 YY_RULE_SETUP
-#line 114 "lexer.l"
+#line 113 "lexer.l"
 { return _ANY_;         }
 	YY_BREAK
 case 31:
 YY_RULE_SETUP
-#line 115 "lexer.l"
+#line 114 "lexer.l"
 { return _ENTRYPOINT_;  }
 	YY_BREAK
 case 32:
 YY_RULE_SETUP
-#line 116 "lexer.l"
+#line 115 "lexer.l"
 { return _FILESIZE_;    }
 	YY_BREAK
 case 33:
 YY_RULE_SETUP
-#line 117 "lexer.l"
+#line 116 "lexer.l"
 { return _UINT8_;       }
 	YY_BREAK
 case 34:
 YY_RULE_SETUP
-#line 118 "lexer.l"
+#line 117 "lexer.l"
 { return _UINT16_;      }
 	YY_BREAK
 case 35:
 YY_RULE_SETUP
-#line 119 "lexer.l"
+#line 118 "lexer.l"
 { return _UINT32_;      }
 	YY_BREAK
 case 36:
 YY_RULE_SETUP
-#line 120 "lexer.l"
+#line 119 "lexer.l"
 { return _INT8_;        }
 	YY_BREAK
 case 37:
 YY_RULE_SETUP
-#line 121 "lexer.l"
+#line 120 "lexer.l"
 { return _INT16_;       }
 	YY_BREAK
 case 38:
 YY_RULE_SETUP
-#line 122 "lexer.l"
+#line 121 "lexer.l"
 { return _INT32_;       }
 	YY_BREAK
 case 39:
 YY_RULE_SETUP
-#line 123 "lexer.l"
+#line 122 "lexer.l"
 { return _MATCHES_;     }
 	YY_BREAK
 case 40:
 YY_RULE_SETUP
-#line 124 "lexer.l"
+#line 123 "lexer.l"
 { return _CONTAINS_;    }
 	YY_BREAK
 case 41:
 YY_RULE_SETUP
-#line 125 "lexer.l"
+#line 124 "lexer.l"
 { return _IMPORT_;      }
 	YY_BREAK
 case 42:
 YY_RULE_SETUP
-#line 128 "lexer.l"
+#line 127 "lexer.l"
 { BEGIN(comment);       }
 	YY_BREAK
 case 43:
 YY_RULE_SETUP
-#line 129 "lexer.l"
+#line 128 "lexer.l"
 { BEGIN(INITIAL);       }
 	YY_BREAK
 case 44:
 /* rule 44 can match eol */
 YY_RULE_SETUP
-#line 130 "lexer.l"
+#line 129 "lexer.l"
 { /* skip comments */   }
 	YY_BREAK
 case 45:
 YY_RULE_SETUP
-#line 133 "lexer.l"
+#line 132 "lexer.l"
 { /* skip single-line comments */ }
 	YY_BREAK
 case 46:
 YY_RULE_SETUP
-#line 136 "lexer.l"
+#line 135 "lexer.l"
 {
                           yyextra->lex_buf_ptr = yyextra->lex_buf;
                           yyextra->lex_buf_len = 0;
@@ -1253,12 +1253,12 @@ YY_RULE_SETUP
 case 47:
 /* rule 47 can match eol */
 YY_RULE_SETUP
-#line 143 "lexer.l"
+#line 142 "lexer.l"
 { YYTEXT_TO_BUFFER; }
 	YY_BREAK
 case 48:
 YY_RULE_SETUP
-#line 146 "lexer.l"
+#line 145 "lexer.l"
 {
 
   char            buffer[1024];
@@ -1364,7 +1364,7 @@ case YY_STATE_EOF(str):
 case YY_STATE_EOF(regexp):
 case YY_STATE_EOF(include):
 case YY_STATE_EOF(comment):
-#line 248 "lexer.l"
+#line 247 "lexer.l"
 {
 
   YR_COMPILER* compiler = yara_yyget_extra(yyscanner);
@@ -1386,7 +1386,7 @@ case YY_STATE_EOF(comment):
 	YY_BREAK
 case 49:
 YY_RULE_SETUP
-#line 268 "lexer.l"
+#line 267 "lexer.l"
 {
 
   yylval->c_string = yr_strdup(yytext);
@@ -1402,7 +1402,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 50:
 YY_RULE_SETUP
-#line 282 "lexer.l"
+#line 281 "lexer.l"
 {
 
   yylval->c_string = yr_strdup(yytext);
@@ -1418,7 +1418,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 51:
 YY_RULE_SETUP
-#line 296 "lexer.l"
+#line 295 "lexer.l"
 {
 
   yylval->c_string = yr_strdup(yytext);
@@ -1435,7 +1435,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 52:
 YY_RULE_SETUP
-#line 311 "lexer.l"
+#line 310 "lexer.l"
 {
 
   yylval->c_string = yr_strdup(yytext);
@@ -1452,7 +1452,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 53:
 YY_RULE_SETUP
-#line 326 "lexer.l"
+#line 325 "lexer.l"
 {
 
   if (strlen(yytext) > 128)
@@ -1473,7 +1473,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 54:
 YY_RULE_SETUP
-#line 345 "lexer.l"
+#line 344 "lexer.l"
 {
 
   yylval->integer = (size_t) atol(yytext);
@@ -1491,7 +1491,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 55:
 YY_RULE_SETUP
-#line 361 "lexer.l"
+#line 360 "lexer.l"
 {
 
   yylval->integer = xtoi(yytext + 2);
@@ -1500,7 +1500,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 56:
 YY_RULE_SETUP
-#line 368 "lexer.l"
+#line 367 "lexer.l"
 {     /* saw closing quote - all done */
 
   SIZED_STRING* s;
@@ -1526,7 +1526,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 57:
 YY_RULE_SETUP
-#line 392 "lexer.l"
+#line 391 "lexer.l"
 {
 
   LEX_CHECK_SPACE_OK("\t", yyextra->lex_buf_len, LEX_BUF_SIZE);
@@ -1536,7 +1536,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 58:
 YY_RULE_SETUP
-#line 400 "lexer.l"
+#line 399 "lexer.l"
 {
 
   LEX_CHECK_SPACE_OK("\n", yyextra->lex_buf_len, LEX_BUF_SIZE);
@@ -1546,7 +1546,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 59:
 YY_RULE_SETUP
-#line 408 "lexer.l"
+#line 407 "lexer.l"
 {
 
   LEX_CHECK_SPACE_OK("\"", yyextra->lex_buf_len, LEX_BUF_SIZE);
@@ -1556,7 +1556,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 60:
 YY_RULE_SETUP
-#line 416 "lexer.l"
+#line 415 "lexer.l"
 {
 
   LEX_CHECK_SPACE_OK("\\", yyextra->lex_buf_len, LEX_BUF_SIZE);
@@ -1566,7 +1566,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 61:
 YY_RULE_SETUP
-#line 424 "lexer.l"
+#line 423 "lexer.l"
 {
 
    int result;
@@ -1579,13 +1579,13 @@ YY_RULE_SETUP
 	YY_BREAK
 case 62:
 YY_RULE_SETUP
-#line 435 "lexer.l"
+#line 434 "lexer.l"
 { YYTEXT_TO_BUFFER; }
 	YY_BREAK
 case 63:
 /* rule 63 can match eol */
 YY_RULE_SETUP
-#line 438 "lexer.l"
+#line 437 "lexer.l"
 {
 
   yyerror(yyscanner, compiler, "unterminated string");
@@ -1595,7 +1595,7 @@ YY_RULE_SETUP
 case 64:
 /* rule 64 can match eol */
 YY_RULE_SETUP
-#line 444 "lexer.l"
+#line 443 "lexer.l"
 {
 
   yyerror(yyscanner, compiler, "illegal escape sequence");
@@ -1603,7 +1603,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 65:
 YY_RULE_SETUP
-#line 450 "lexer.l"
+#line 449 "lexer.l"
 {
 
   SIZED_STRING* s;
@@ -1636,7 +1636,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 66:
 YY_RULE_SETUP
-#line 481 "lexer.l"
+#line 480 "lexer.l"
 {
 
   LEX_CHECK_SPACE_OK("/", yyextra->lex_buf_len, LEX_BUF_SIZE);
@@ -1646,7 +1646,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 67:
 YY_RULE_SETUP
-#line 489 "lexer.l"
+#line 488 "lexer.l"
 {
 
   LEX_CHECK_SPACE_OK("\\.", yyextra->lex_buf_len, LEX_BUF_SIZE);
@@ -1657,13 +1657,13 @@ YY_RULE_SETUP
 	YY_BREAK
 case 68:
 YY_RULE_SETUP
-#line 498 "lexer.l"
+#line 497 "lexer.l"
 { YYTEXT_TO_BUFFER; }
 	YY_BREAK
 case 69:
 /* rule 69 can match eol */
 YY_RULE_SETUP
-#line 501 "lexer.l"
+#line 500 "lexer.l"
 {
 
   yyerror(yyscanner, compiler, "unterminated regular expression");
@@ -1672,7 +1672,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 70:
 YY_RULE_SETUP
-#line 508 "lexer.l"
+#line 507 "lexer.l"
 {
 
   yyextra->lex_buf_ptr = yyextra->lex_buf;
@@ -1682,7 +1682,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 71:
 YY_RULE_SETUP
-#line 516 "lexer.l"
+#line 515 "lexer.l"
 {
 
   yyextra->lex_buf_ptr = yyextra->lex_buf;
@@ -1693,7 +1693,7 @@ YY_RULE_SETUP
 case 72:
 /* rule 72 can match eol */
 YY_RULE_SETUP
-#line 524 "lexer.l"
+#line 523 "lexer.l"
 {
 
   int len = strlen(yytext);
@@ -1711,12 +1711,12 @@ YY_RULE_SETUP
 case 73:
 /* rule 73 can match eol */
 YY_RULE_SETUP
-#line 539 "lexer.l"
+#line 538 "lexer.l"
 /* skip whitespace */
 	YY_BREAK
 case 74:
 YY_RULE_SETUP
-#line 541 "lexer.l"
+#line 540 "lexer.l"
 {
 
   if (yytext[0] >= 32 && yytext[0] < 127)
@@ -1732,7 +1732,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 75:
 YY_RULE_SETUP
-#line 554 "lexer.l"
+#line 553 "lexer.l"
 ECHO;
 	YY_BREAK
 #line 1739 "lexer.c"
@@ -2868,7 +2868,7 @@ void yara_yyfree (void * ptr , yyscan_t yyscanner)
 
 #define YYTABLES_NAME "yytables"
 
-#line 554 "lexer.l"
+#line 553 "lexer.l"
 
 
 
diff --git a/libyara/lexer.l b/libyara/lexer.l
index 25c948e..92126ab 100644
--- a/libyara/lexer.l
+++ b/libyara/lexer.l
@@ -26,11 +26,10 @@ limitations under the License.
 
 
 #include <yara/lexer.h>
-#include <yara/rules.h>
 #include <yara/sizedstr.h>
 #include <yara/error.h>
 #include <yara/mem.h>
-#include <yara/utils.h>
+#include <yara/strings.h>
 
 #include "grammar.h"
 
diff --git a/libyara/utils.c b/libyara/strutils.c
similarity index 88%
rename from libyara/utils.c
rename to libyara/strutils.c
index 730e34a..4d4c170 100644
--- a/libyara/utils.c
+++ b/libyara/strutils.c
@@ -17,15 +17,16 @@ limitations under the License.
 #include <stdio.h>
 #include <string.h>
 
+#include <yara/strutils.h>
+
 #include "config.h"
 
-size_t xtoi(const char* hexstr)
+uint64_t xtoi(const char* hexstr)
 {
-  size_t r = 0;
-  int i;
   int l = strlen(hexstr);
+  uint64_t r = 0;
 
-  for (i = 0; i < l; i++)
+  for (int i = 0; i < l; i++)
   {
     switch(hexstr[i])
     {
@@ -39,7 +40,7 @@ size_t xtoi(const char* hexstr)
       case '7':
       case '8':
       case '9':
-        r |= ((size_t)(hexstr[i] - '0')) << ((l - i - 1) * 4);
+        r |= ((uint64_t)(hexstr[i] - '0')) << ((l - i - 1) * 4);
         break;
       case 'a':
       case 'b':
@@ -47,7 +48,7 @@ size_t xtoi(const char* hexstr)
       case 'd':
       case 'e':
       case 'f':
-        r |= ((size_t)(hexstr[i] - 'a' + 10)) << ((l - i - 1) * 4);
+        r |= ((uint64_t)(hexstr[i] - 'a' + 10)) << ((l - i - 1) * 4);
         break;
       case 'A':
       case 'B':
@@ -55,7 +56,7 @@ size_t xtoi(const char* hexstr)
       case 'D':
       case 'E':
       case 'F':
-        r |= ((size_t)(hexstr[i] - 'A' + 10)) << ((l - i - 1) * 4);
+        r |= ((uint64_t)(hexstr[i] - 'A' + 10)) << ((l - i - 1) * 4);
         break;
       default:
         i = l;  // force loop exit
@@ -65,8 +66,6 @@ size_t xtoi(const char* hexstr)
   return r;
 }
 
-
-
 /*
 
 strlcpy and strlcat are defined in FreeBSD and OpenBSD,

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