From fb701ce7c56b1cd67699635d7b5b88ffae64559f Mon Sep 17 00:00:00 2001 From: Andrew Stubbs Date: Tue, 9 Oct 2012 15:17:19 +0100 Subject: [PATCH] Detect __DATE__ and __TIME__ correctly The code to detect __DATE__ and __TIME__ was off-by-one, and therefore totally failed to detect time macros unless by chance alignments (1 in eight macros might be correctly aligned). The problem is that the code expects that 'i' will point to the last underscore, and the skip table expects 'i' to point to the point after the end of the string. For example, if str[i] == 'E' then the skip table moves 'i' on 3 bytes, whereas the code only works with a 2-byte skip. I've corrected the problem by adjusting the table to match the code. I've confirmed the tests still pass. Signed-off-by: Andrew Stubbs --- macroskip.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/macroskip.h b/macroskip.h index 14522018a..cb32ec4dc 100644 --- a/macroskip.h +++ b/macroskip.h @@ -7,23 +7,23 @@ * The other characters map as follows: * * _ -> 1 - * A -> 5 - * D -> 6 - * E -> 3 - * I -> 5 - * M -> 4 - * T -> 4 + * A -> 4 + * D -> 5 + * E -> 2 + * I -> 4 + * M -> 3 + * T -> 3 * * * This was generated with the following Python script: * * m = {'_': 1, - * 'A': 5, - * 'D': 6, - * 'E': 3, - * 'I': 5, - * 'M': 4, - * 'T': 4} + * 'A': 4, + * 'D': 5, + * 'E': 2, + * 'I': 4, + * 'M': 3, + * 'T': 3} * * for i in range(0, 256): * if chr(i) in m: @@ -41,8 +41,8 @@ static const uint32_t macro_skip[] = { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 5, 8, 8, 6, 3, 8, 8, 8, 5, 8, 8, 8, 4, 8, 8, - 8, 8, 8, 8, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1, + 8, 4, 8, 8, 5, 2, 8, 8, 8, 4, 8, 8, 8, 3, 8, 8, + 8, 8, 8, 8, 3, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, -- 2.47.3