tools/kconfig2html.c: Update to handle absolute paths when sourcing Kconfig files.

This commit is contained in:
Gregory Nutt 2016-07-29 13:11:30 -06:00
parent 486212a750
commit 5ddeffdef8

View File

@ -2245,16 +2245,24 @@ static char *parse_kconfigfile(FILE *stream, const char *kconfigdir)
{ {
/* Get the relative path from the Kconfig file line */ /* Get the relative path from the Kconfig file line */
char *relpath = get_token(); char *source = get_token();
/* Remove optional quoting */ /* Remove optional quoting */
relpath = dequote(relpath); source = dequote(source);
if (relpath) if (source)
{ {
char *subdir = dirname(relpath); char *subdir = dirname(source);
char *dirpath; char *dirpath;
/* Check for an absolute path */
if (source[0] == '/')
{
dirpath = strdup(subdir);
}
else
{
/* Check if the directory path contains $APPSDIR */ /* Check if the directory path contains $APPSDIR */
char *appsdir = strstr(subdir, "$APPSDIR"); char *appsdir = strstr(subdir, "$APPSDIR");
@ -2263,15 +2271,18 @@ static char *parse_kconfigfile(FILE *stream, const char *kconfigdir)
char *tmp = appsdir + strlen("$APPSDIR"); char *tmp = appsdir + strlen("$APPSDIR");
*appsdir = '\0'; *appsdir = '\0';
asprintf(&dirpath, "%s/%s%s%s", g_kconfigroot, subdir, g_appsdir, tmp); asprintf(&dirpath, "%s/%s%s%s",
g_kconfigroot, subdir, g_appsdir, tmp);
} }
else else
{ {
asprintf(&dirpath, "%s/%s", g_kconfigroot, subdir); asprintf(&dirpath, "%s/%s", g_kconfigroot, subdir);
} }
}
debug("parse_kconfigfile: Recursing for TOKEN_SOURCE\n"); debug("parse_kconfigfile: Recursing for TOKEN_SOURCE\n");
debug(" relpath: %s\n", relpath); debug(" source: %s\n", source);
debug(" subdir: %s\n", subdir); debug(" subdir: %s\n", subdir);
debug(" dirpath: %s\n", dirpath); debug(" dirpath: %s\n", dirpath);