[ccache] Minor enhancement request: Handling of CCACHE_PREFIX when it is defined as a null string

2012-02-07 Thread Frank Klotz
  Could a CCACHE_PREFIX defined as a null string please be treated as 
if it were undefined, rather than as a fatal error?


Yes, of course, I can fix this in my script by making sure I undefine it 
if I don't want a prefix, but I got a little surprised when resetting it 
from distcc to  caused a fatal ccache failure.  And it was a bit 
nasty to debug.


I think I see two places in ccache.c that would be affected here:

Around line 218:
 if ((e = getenv(CCACHE_PREFIX))) {
 char *p = find_executable(e, MYNAME);
 if (!p) {
 fatal(%s: %s, e, strerror(errno));
 }
 args_add_prefix(orig_args, p);
 }

(Change that first line to something like this?
 if ((e = getenv(CCACHE_PREFIX))  strlen (e)  0) {
)

And line 1944:
 env = getenv(CCACHE_PREFIX);
 if (env) {
 char *p = find_executable(env, MYNAME);
 if (!p) {
 fatal(%s: %s, env, strerror(errno));
 }
 cc_log(Using command-line prefix %s, env);
 args_add_prefix(compiler_args, p);
 }

And change the second line here to
 if (env  strlen (env)  0) {

And you might want to consider refactoring this 
almost-but-not-quite-identical code into a function or macro - not sure 
why there are two versions


Thanks,
Frank Klotz
___
ccache mailing list
ccache@lists.samba.org
https://lists.samba.org/mailman/listinfo/ccache


Re: [ccache] Minor enhancement request: Handling of CCACHE_PREFIX when it is defined as a null string

2012-02-07 Thread Joel Rosdahl
On 7 February 2012 19:38, Frank Klotz frank.kl...@alcatel-lucent.com wrote:
 Could a CCACHE_PREFIX defined as a null string please be treated as if it
 were undefined, rather than as a fatal error?
 [...]
 And you might want to consider refactoring this
 almost-but-not-quite-identical code into a function or macro - not sure why
 there are two versions

These are both good suggestions, and they have actually already been
done over a year ago on the master branch along with allowing several
binaries in CCACHE_PREFIX:
http://git.samba.org/?p=ccache.git;a=commit;h=b453d43ac0dc7097bb8afb74db70ccf5cde3a914

-- Joel
___
ccache mailing list
ccache@lists.samba.org
https://lists.samba.org/mailman/listinfo/ccache