Implement compare_executable_name() helper function

This commit is contained in:
Ramiro Polla 2010-07-15 15:18:34 -03:00 committed by Joel Rosdahl
parent 82b7876473
commit 6014657219
3 changed files with 12 additions and 2 deletions

View File

@ -1263,7 +1263,7 @@ static void find_compiler(int argc, char **argv)
base = basename(argv[0]);
/* we might be being invoked like "ccache gcc -c foo.c" */
if (strcmp(base, MYNAME) == 0) {
if (compare_executable_name(base, MYNAME)) {
args_remove_first(orig_args);
free(base);
if (strchr(argv[1],'/')) {
@ -2127,7 +2127,7 @@ int main(int argc, char *argv[])
/* check if we are being invoked as "ccache" */
program_name = basename(argv[0]);
if (strcmp(program_name, MYNAME) == 0) {
if (compare_executable_name(program_name, MYNAME)) {
if (argc < 2) {
fputs(USAGE_TEXT, stderr);
exit(1);

View File

@ -105,6 +105,7 @@ char *gnu_getcwd(void);
int create_empty_file(const char *fname);
const char *get_home_directory(void);
char *get_cwd();
int compare_executable_name(const char *s1, const char *s2);
size_t common_dir_prefix_length(const char *s1, const char *s2);
char *get_relative_path(const char *from, const char *to);
int is_absolute_path(const char *path);

9
util.c
View File

@ -878,6 +878,15 @@ char *get_cwd(void)
}
}
/*
* Check whether s1 and s2 have the same executable name.
*/
int
compare_executable_name(const char *s1, const char *s2)
{
return !strcmp(s1, s2);
}
/*
* Compute the length of the longest directory path that is common to two
* strings.