diff --git a/tools/kconfig2html.c b/tools/kconfig2html.c
index 295d4814e8..d8ccef63b1 100644
--- a/tools/kconfig2html.c
+++ b/tools/kconfig2html.c
@@ -2245,33 +2245,44 @@ static char *parse_kconfigfile(FILE *stream, const char *kconfigdir)
{
/* Get the relative path from the Kconfig file line */
- char *relpath = get_token();
+ char *source = get_token();
/* Remove optional quoting */
- relpath = dequote(relpath);
- if (relpath)
+ source = dequote(source);
+ if (source)
{
- char *subdir = dirname(relpath);
+ char *subdir = dirname(source);
char *dirpath;
- /* Check if the directory path contains $APPSDIR */
+ /* Check for an absolute path */
- char *appsdir = strstr(subdir, "$APPSDIR");
- if (appsdir)
+ if (source[0] == '/')
{
- char *tmp = appsdir + strlen("$APPSDIR");
-
- *appsdir = '\0';
- asprintf(&dirpath, "%s/%s%s%s", g_kconfigroot, subdir, g_appsdir, tmp);
+ dirpath = strdup(subdir);
}
else
{
- asprintf(&dirpath, "%s/%s", g_kconfigroot, subdir);
+ /* Check if the directory path contains $APPSDIR */
+
+ char *appsdir = strstr(subdir, "$APPSDIR");
+ if (appsdir)
+ {
+ char *tmp = appsdir + strlen("$APPSDIR");
+
+ *appsdir = '\0';
+ asprintf(&dirpath, "%s/%s%s%s",
+ g_kconfigroot, subdir, g_appsdir, tmp);
+ }
+ else
+ {
+ asprintf(&dirpath, "%s/%s", g_kconfigroot, subdir);
+ }
+
}
debug("parse_kconfigfile: Recursing for TOKEN_SOURCE\n");
- debug(" relpath: %s\n", relpath);
+ debug(" source: %s\n", source);
debug(" subdir: %s\n", subdir);
debug(" dirpath: %s\n", dirpath);