[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Calc; Fix c type hex parse on `quick-calc'
From: |
Eli Zaretskii |
Subject: |
Re: Calc; Fix c type hex parse on `quick-calc' |
Date: |
Sat, 18 Nov 2017 12:34:41 +0200 |
> From: OGAWA Hirofumi <address@hidden>
> Date: Fri, 10 Nov 2017 03:31:00 +0900
>
> This bug is reproducible with following commands.
>
> $ emacs -Q
> M-: (setq calc-language 'c)
> M-x quick-calc
>
> Quick calc: 1024 + 0x20
> Result: 32 => 32 (0x20, 040, 2#100000, " ")
>
> Like above, the result is wrong (expected result is following).
> Result: 1024 + 32 => 1056 (0x420, 02040, 2#10000100000)
>
> The bug is in `math-read-token'.
>
> (or (and (memq calc-language calc-lang-c-type-hex)
> (string-match "0[xX][0-9a-fA-F]+" math-exp-str math-exp-pos))
>
> We want to get "1024" as token at first, but the above part matches at
> "0x20" part of expr, and skips "1024 + ".
>
> In this context, we want to check if current token is matching to
> c-type hex or not. So we should check regex is matched at
> math-exp-pos. This patch fixes this bug.
Thanks, I installed your changes.