X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=exp%2Fexpression-parser.l;h=50bd38320bbaedc2eec487d0e8d09b95d95faa7b;hb=dbf2214cd45a3aac0e230d9a2d7fe95a069d107f;hp=d659c4f3af3b394e048fe9e98ad106c70505ac37;hpb=3fcc6ca7f15db70b9f82df1f9065765b4cca4e9d;p=fio.git diff --git a/exp/expression-parser.l b/exp/expression-parser.l index d659c4f3..50bd3832 100644 --- a/exp/expression-parser.l +++ b/exp/expression-parser.l @@ -24,24 +24,27 @@ #define YYSTYPE PARSER_VALUE_TYPE -extern int lexer_input(char* buffer, size_t *nbytes, int buffersize); +extern int lexer_input(char *buffer, unsigned int *nbytes, int buffersize); #undef YY_INPUT -#define YY_INPUT(buffer, bytes_read, bytes_requested) \ -({ \ - int __ret; \ - size_t __bread = bytes_read; \ +#define YY_INPUT(buffer, bytes_read, bytes_requested) \ +({ \ + int __ret; \ + unsigned int __bread = bytes_read; \ __ret = lexer_input((buffer), &__bread, (bytes_requested)); \ bytes_read = __bread; \ - __ret; \ + __ret; \ }) extern int yyerror(long long *result, double *dresult, int *has_error, int *units_specified, const char *msg); -static void __attribute__((unused)) yyunput(int c,char *buf_ptr); +static void __attribute__((unused)) yyunput(int c, char *buf_ptr); static int __attribute__((unused)) input(void); +/* set by parser -- this is another thing which makes the parser thread-unsafe :(. */ +int lexer_value_is_time = 0; /* for determining if "m" suffix means mega- or minutes */ + #define set_suffix_value(yylval, i_val, d_val, has_d_val) \ (yylval).v.dval = (d_val); \ (yylval).v.ival = (i_val); \ @@ -57,7 +60,7 @@ static int __attribute__((unused)) input(void); set_suffix_value(yylval, 1024, 1024.0, 0); return SUFFIX; } -[Mm]|[Mm][bB] { +[Mm][bB] { set_suffix_value(yylval, 1024 * 1024, 1024.0 * 1024.0, 0); return SUFFIX; } @@ -103,6 +106,14 @@ static int __attribute__((unused)) input(void); set_suffix_value(yylval, 1000000LL, 1000000.0 , 0); return SUFFIX; } +[mM] { + if (!lexer_value_is_time) { + set_suffix_value(yylval, 1024 * 1024, 1024.0 * 1024.0, 0); + } else { + set_suffix_value(yylval, 60LL * 1000000LL, 60.0 * 1000000.0, 0); + } + return SUFFIX; + } [dD] { set_suffix_value(yylval, 60LL * 60LL * 24LL * 1000000LL, 60.0 * 60.0 * 24.0 * 1000000.0, 0);