]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Support the HP compiler's preprocessor format
authorJoel Rosdahl <joel@rosdahl.net>
Thu, 3 Jun 2010 21:12:44 +0000 (23:12 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Thu, 3 Jun 2010 21:12:44 +0000 (23:12 +0200)
ccache.c

index 232d02a64c9ccdc137ff41a9a3f366d71916785d..0acf649f80445888ed5d63b7255db1854957dfb0 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -458,8 +458,30 @@ static int process_preprocessed_file(struct mdfour *hash, const char *path)
        end = data + size;
        p = data;
        q = data;
-       while (q < end - 1) {
-               if (q[0] == '#' && q[1] == ' ' /* Need to avoid "#pragma"... */
+       while (q < end - 7) { /* There must be at least 7 characters (# 1 "x") left
+                                to potentially find an include file path. */
+               /*
+                * Check if we look at a line containing the file name of an included file.
+                * At least the following formats exist (where N is a positive integer):
+                *
+                * GCC:
+                *
+                *   # N "file"
+                *   # N "file" N
+                *
+                * HP's compiler:
+                *
+                *   #line N "file"
+                *
+                * Note that there may be other lines starting with '#' left after
+                * preprocessing as well, for instance "#    pragma".
+                */
+               if (q[0] == '#'
+                       /* GCC: */
+                   && ((q[1] == ' ' && q[2] >= '0' && q[2] <= '9')
+                       /* HP: */
+                       || (q[1] == 'l' && q[2] == 'i' && q[3] == 'n' && q[4] == 'e'
+                           && q[5] == ' '))
                    && (q == data || q[-1] == '\n')) {
                        char *path;