exp: fix issues around int vs size_t
[fio.git] / exp / expression-parser.l
index f688da11684e16b68b88df9a1837c894e8b484b3..d659c4f3af3b394e048fe9e98ad106c70505ac37 100644 (file)
 
 #define YYSTYPE PARSER_VALUE_TYPE
 
-extern int lexer_input(char* buffer, int *nbytes, int buffersize);
+extern int lexer_input(char* buffer, size_t *nbytes, int buffersize);
 
 #undef YY_INPUT
-#define YY_INPUT(buffer, bytes_read, bytes_requested) \
-               lexer_input((buffer), &(bytes_read), (bytes_requested))
+#define YY_INPUT(buffer, bytes_read, bytes_requested)  \
+({                                                     \
+       int __ret;                                      \
+       size_t __bread = bytes_read;                    \
+       __ret = lexer_input((buffer), &__bread, (bytes_requested));     \
+       bytes_read = __bread;                                           \
+       __ret;                                          \
+})
 
 extern int yyerror(long long *result, double *dresult,
-               int *has_error, int *bye, const char *msg);
+               int *has_error, int *units_specified, const char *msg);
 
 static void __attribute__((unused)) yyunput(int c,char *buf_ptr);
 static int __attribute__((unused)) input(void);
@@ -47,7 +53,6 @@ static int __attribute__((unused)) input(void);
 %%
 
 
-bye            return BYE;
 [kK]|[kK][bB]  {
                        set_suffix_value(yylval, 1024, 1024.0, 0);
                        return SUFFIX;
@@ -109,8 +114,8 @@ bye         return BYE;
                        return SUFFIX;
                }
 [ \t] ; /* ignore whitespace */
-#.+ ; /* ignore comments */
-[0-9]*[.][0-9]+ {
+[#:,].* ; /* ignore comments, and everything after colons and commas */
+[0-9]*[.][0-9]+|[0-9]*[.]?[0-9]+[eE][-+]*[0-9]+ {
                        int rc;
                        double dval;
 
@@ -158,7 +163,8 @@ bye         return BYE;
                }
        }
 \n     return 0;
-[+-/*()]       return yytext[0];
+[+-/*()^%]     return yytext[0];
+
 .      {
                yylval.v.has_error = 1;
                return NUMBER;