]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Detect __DATE__ and __TIME__ correctly
authorAndrew Stubbs <ams@codesourcery.com>
Tue, 9 Oct 2012 14:17:19 +0000 (15:17 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 4 Nov 2012 21:07:00 +0000 (22:07 +0100)
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 <ams@codesourcery.com>
macroskip.h

index 14522018ac4d705974ea729bfe3533b9bdbd4252..cb32ec4dcf3785d31fdca96eedefdf6c1268ea83 100644 (file)
@@ -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,