[ccache] preprocessing with -P
Giulio Eulisse
giulio.eulisse at cern.ch
Wed Dec 3 16:07:55 GMT 2003
> >> Maybe a better solution would be to remove lines with # when generating
> >> the hash, but to keep them when compiling....
>
> Yes - I think that is possible.
> If it works - it would be a nice feature for us too.
Try this...It's a quick hack, but it seems to work for me...
Ciao again,
Giulio
cvs server: Diffing .
Index: hash.c
===================================================================
RCS file: /cvsroot/ccache/hash.c,v
retrieving revision 1.9
diff -u -r1.9 hash.c
--- hash.c 29 Apr 2002 09:12:40 -0000 1.9
+++ hash.c 3 Dec 2003 15:59:20 -0000
@@ -20,6 +20,8 @@
*/
#include "ccache.h"
+#include <stdio.h>
+#include <string.h>
static struct mdfour md;
@@ -43,13 +45,25 @@
hash_buffer((char *)&x, sizeof(x));
}
+
/* add contents of a file to the hash */
void hash_file(const char *fname)
{
char buf[1024];
int fd, n;
- fd = open(fname, O_RDONLY);
+ static const char *cmd1 = "/bin/cat <";
+ static const char *cmd2 = "|/bin/grep -v \"^#\"";
+ static char cmd[4096];
+
+ cmd[0] = 0;
+ strcat(cmd, cmd1);
+ strcat(cmd, fname);
+ strcat(cmd, cmd2);
+
+ FILE *file = popen(cmd, "r");
+ fd = fileno(file);
+
if (fd == -1) {
cc_log("Failed to open %s\n", fname);
fatal("hash_file");
@@ -58,7 +72,8 @@
while ((n = read(fd, buf, sizeof(buf))) > 0) {
hash_buffer(buf, n);
}
- close(fd);
+
+ pclose(file);
}
/* return the hash result as a static string */
cvs server: Diffing packaging
cvs server: Diffing web
More information about the ccache
mailing list