fast replace if src outside
This commit is contained in:
parent
0b42a6a8cf
commit
6c0642d772
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Another fast dependencies generator for Makefiles, Version 2.4
|
* Another fast dependencies generator for Makefiles, Version 2.5
|
||||||
*
|
*
|
||||||
* Copyright (C) 2005 by Vladimir Oleynik <dzo@simtreas.ru>
|
* Copyright (C) 2005 by Vladimir Oleynik <dzo@simtreas.ru>
|
||||||
* mmaping file may be originally by Linus Torvalds.
|
* mmaping file may be originally by Linus Torvalds.
|
||||||
@ -97,7 +97,11 @@ static void parse_conf_opt(const char *opt, const char *val,
|
|||||||
static char first_chars[257]; /* + L_EOF */
|
static char first_chars[257]; /* + L_EOF */
|
||||||
static char isalnums[257]; /* + L_EOF */
|
static char isalnums[257]; /* + L_EOF */
|
||||||
/* trick for fast find "define", "include", "undef" */
|
/* trick for fast find "define", "include", "undef" */
|
||||||
static char first_chars_diu[256];
|
static char first_chars_diu[256] = {
|
||||||
|
[(int)'d'] = (char)5, /* strlen("define") - 1; */
|
||||||
|
[(int)'i'] = (char)6, /* strlen("include") - 1; */
|
||||||
|
[(int)'u'] = (char)4, /* strlen("undef") - 1; */
|
||||||
|
};
|
||||||
|
|
||||||
static int pagesizem1;
|
static int pagesizem1;
|
||||||
static size_t mema_id = 128; /* first allocated for id */
|
static size_t mema_id = 128; /* first allocated for id */
|
||||||
@ -136,7 +140,6 @@ static char *id_s;
|
|||||||
id[id_len++] = c; } while(0)
|
id[id_len++] = c; } while(0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* stupid C lexical analyser */
|
/* stupid C lexical analyser */
|
||||||
static void c_lex(const char *fname, long fsize)
|
static void c_lex(const char *fname, long fsize)
|
||||||
{
|
{
|
||||||
@ -605,14 +608,19 @@ static void parse_conf_opt(const char *opt, const char *val,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int show_dep(int first, bb_key_t *k, const char *name)
|
static char *pwd;
|
||||||
|
|
||||||
|
static int show_dep(int first, bb_key_t *k, const char *name, const char *f)
|
||||||
{
|
{
|
||||||
bb_key_t *cur;
|
bb_key_t *cur;
|
||||||
|
|
||||||
for(cur = k; cur; cur = cur->next) {
|
for(cur = k; cur; cur = cur->next) {
|
||||||
if(cur->checked) {
|
if(cur->checked) {
|
||||||
if(first) {
|
if(first) {
|
||||||
printf("\n%s:", name);
|
if(f == NULL)
|
||||||
|
printf("\n%s:", name);
|
||||||
|
else
|
||||||
|
printf("\n%s/%s:", pwd, name);
|
||||||
first = 0;
|
first = 0;
|
||||||
} else {
|
} else {
|
||||||
printf(" \\\n ");
|
printf(" \\\n ");
|
||||||
@ -624,8 +632,7 @@ static int show_dep(int first, bb_key_t *k, const char *name)
|
|||||||
return first;
|
return first;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *pwd;
|
static size_t replace;
|
||||||
static char *replace;
|
|
||||||
|
|
||||||
static struct stat st_kp;
|
static struct stat st_kp;
|
||||||
static int dontgenerate_dep;
|
static int dontgenerate_dep;
|
||||||
@ -673,23 +680,17 @@ parse_chd(const char *fe, const char *p, size_t dirlen)
|
|||||||
if(*e == 'c') {
|
if(*e == 'c') {
|
||||||
/* *.c -> *.o */
|
/* *.c -> *.o */
|
||||||
*e = 'o';
|
*e = 'o';
|
||||||
if(replace) {
|
/* /src_dir/path/file.o to path/file.o */
|
||||||
/* /src_dir/path/file.o to path/file.o */
|
fp += replace;
|
||||||
e = fp + strlen(replace);
|
if(*fp == '/')
|
||||||
while(*e == '/')
|
fp++;
|
||||||
e++;
|
|
||||||
/* path/file.o to pwd/path/file.o */
|
|
||||||
e = fp = bb_asprint("%s/%s", pwd, e);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
e = NULL;
|
e = NULL;
|
||||||
}
|
}
|
||||||
first = show_dep(1, Ifound, fp);
|
first = show_dep(1, Ifound, fp, e);
|
||||||
first = show_dep(first, key_top, fp);
|
first = show_dep(first, key_top, fp, e);
|
||||||
if(first == 0)
|
if(first == 0)
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
if(replace && e)
|
|
||||||
free(e);
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
} else if(S_ISDIR(st.st_mode)) {
|
} else if(S_ISDIR(st.st_mode)) {
|
||||||
@ -726,10 +727,7 @@ static void scan_dir_find_ch_files(const char *p)
|
|||||||
size_t dirlen;
|
size_t dirlen;
|
||||||
|
|
||||||
dirs = llist_add_to(NULL, bb_simplify_path(p));
|
dirs = llist_add_to(NULL, bb_simplify_path(p));
|
||||||
if(strcmp(dirs->data, pwd))
|
replace = strlen(dirs->data);
|
||||||
replace = bb_xstrdup(dirs->data);
|
|
||||||
else
|
|
||||||
replace = NULL;
|
|
||||||
/* emulate recursive */
|
/* emulate recursive */
|
||||||
while(dirs) {
|
while(dirs) {
|
||||||
d_add = NULL;
|
d_add = NULL;
|
||||||
@ -755,8 +753,6 @@ static void scan_dir_find_ch_files(const char *p)
|
|||||||
}
|
}
|
||||||
dirs = d_add;
|
dirs = d_add;
|
||||||
}
|
}
|
||||||
free(replace);
|
|
||||||
replace = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -832,10 +828,6 @@ int main(int argc, char **argv)
|
|||||||
first_chars[i] = ANY;
|
first_chars[i] = ANY;
|
||||||
}
|
}
|
||||||
first_chars[i] = '-'; /* L_EOF */
|
first_chars[i] = '-'; /* L_EOF */
|
||||||
/* trick for fast find "define", "include", "undef" */
|
|
||||||
first_chars_diu[(int)'d'] = (char)5; /* strlen("define") - 1; */
|
|
||||||
first_chars_diu[(int)'i'] = (char)6; /* strlen("include") - 1; */
|
|
||||||
first_chars_diu[(int)'u'] = (char)4; /* strlen("undef") - 1; */
|
|
||||||
|
|
||||||
/* parse configs */
|
/* parse configs */
|
||||||
for(fl = configs; fl; fl = fl->link) {
|
for(fl = configs; fl; fl = fl->link) {
|
||||||
|
Loading…
Reference in New Issue
Block a user