Fixes regressions in Wine's d3dcompiler asm tests.
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- libs/vkd3d-shader/preproc.l | 10 +++++----- libs/vkd3d-shader/preproc.y | 8 ++++++++ 2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/libs/vkd3d-shader/preproc.l b/libs/vkd3d-shader/preproc.l index 7686e018..00a4458a 100644 --- a/libs/vkd3d-shader/preproc.l +++ b/libs/vkd3d-shader/preproc.l @@ -91,13 +91,13 @@ INT_SUFFIX [uUlL]{0,2}
/* We have no use for floats, but shouldn't parse them as integers. */
-<INITIAL>[0-9]*.[0-9]+([eE][+-]?[0-9]+)?[hHfF]? {return T_TEXT;} -<INITIAL>[0-9]+.([eE][+-]?[0-9]+)?[hHfF]? {return T_TEXT;} -<INITIAL>[0-9]+([eE][+-]?[0-9]+)?[hHfF] {return T_TEXT;} -<INITIAL>[0-9]+[eE][+-]?[0-9]+ {return T_TEXT;} +<INITIAL>-?[0-9]*.[0-9]+([eE][+-]?[0-9]+)?[hHfF]? {return T_TEXT;} +<INITIAL>-?[0-9]+.([eE][+-]?[0-9]+)?[hHfF]? {return T_TEXT;} +<INITIAL>-?[0-9]+([eE][+-]?[0-9]+)?[hHfF] {return T_TEXT;} +<INITIAL>-?[0-9]+[eE][+-]?[0-9]+ {return T_TEXT;} <INITIAL,LINE>0[xX][0-9a-fA-f]+{INT_SUFFIX} {return T_INTEGER;} <INITIAL,LINE>0[0-7]*{INT_SUFFIX} {return T_INTEGER;} -<INITIAL,LINE>[1-9][0-9]*{INT_SUFFIX} {return T_INTEGER;} +<INITIAL,LINE>-?[1-9][0-9]*{INT_SUFFIX} {return T_INTEGER;}
<INITIAL>## {return T_CONCAT;}
diff --git a/libs/vkd3d-shader/preproc.y b/libs/vkd3d-shader/preproc.y index 3f02ac03..5dd7929a 100644 --- a/libs/vkd3d-shader/preproc.y +++ b/libs/vkd3d-shader/preproc.y @@ -179,8 +179,14 @@ static int char_to_int(char c) static uint32_t preproc_parse_integer(const char *s) { uint32_t base = 10, ret = 0; + bool sign = false; int digit;
+ if (*s == '-') + { + sign = true; + ++s; + } if (*s == '0') { base = 8; @@ -194,6 +200,8 @@ static uint32_t preproc_parse_integer(const char *s)
while ((digit = char_to_int(*s++)) >= 0) ret = ret * base + (uint32_t)digit; + if (sign) + ret = -ret; return ret; }