From patchwork Sun Jan 30 23:15:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yann E. MORIN" X-Patchwork-Id: 518271 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0UNUCQs007293 for ; Sun, 30 Jan 2011 23:32:07 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754924Ab1A3XPb (ORCPT ); Sun, 30 Jan 2011 18:15:31 -0500 Received: from smtp08.smtpout.orange.fr ([80.12.242.130]:45466 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754877Ab1A3XP3 (ORCPT ); Sun, 30 Jan 2011 18:15:29 -0500 Received: from roazhon.bzh.lan ([90.32.36.240]) by mwinf5d31 with ME id 1zFQ1g0025AsJje03zFSDm; Mon, 31 Jan 2011 00:15:26 +0100 From: "Yann E. MORIN" To: linux-kbuild@vger.kernel.org Subject: [PATCH 1/2] kconfig: allow multiple inclusion of the same file Date: Mon, 31 Jan 2011 00:15:20 +0100 Message-Id: <1296429321-6991-2-git-send-email-yann.morin.1998@anciens.enib.fr> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1296429321-6991-1-git-send-email-yann.morin.1998@anciens.enib.fr> References: <1296429321-6991-1-git-send-email-yann.morin.1998@anciens.enib.fr> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sun, 30 Jan 2011 23:32:07 +0000 (UTC) different files, and/or under different conditions). To avoid circular inclusion, scan the source-ancestry of the current file, and abort if already sourced in this branch. Regenerate the pre-parsed lex.zconf.c_shipped file. Signed-off-by: "Yann E. MORIN" --- scripts/kconfig/lex.zconf.c_shipped | 29 +++++++++++++++++++---------- scripts/kconfig/zconf.l | 29 +++++++++++++++++++---------- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/scripts/kconfig/lex.zconf.c_shipped b/scripts/kconfig/lex.zconf.c_shipped index 6eb0397..f4b3b1a 100644 --- a/scripts/kconfig/lex.zconf.c_shipped +++ b/scripts/kconfig/lex.zconf.c_shipped @@ -2368,6 +2368,7 @@ void zconf_initscan(const char *name) void zconf_nextfile(const char *name) { + struct file *iter; struct file *file = file_lookup(name); struct buffer *buf = malloc(sizeof(*buf)); memset(buf, 0, sizeof(*buf)); @@ -2383,16 +2384,24 @@ void zconf_nextfile(const char *name) buf->parent = current_buf; current_buf = buf; - if (file->flags & FILE_BUSY) { - printf("%s:%d: do not source '%s' from itself\n", - zconf_curname(), zconf_lineno(), name); - exit(1); - } - if (file->flags & FILE_SCANNED) { - printf("%s:%d: file '%s' is already sourced from '%s'\n", - zconf_curname(), zconf_lineno(), name, - file->parent->name); - exit(1); + for (iter = current_file->parent; iter; iter = iter->parent ) { + if (!strcmp(current_file->name,iter->name) ) { + printf("%s:%d: recursive inclusion detected. " + "Inclusion path:\n current file : '%s'\n", + zconf_curname(), zconf_lineno(), + zconf_curname()); + iter = current_file->parent; + while (iter && \ + strcmp(iter->name,current_file->name)) { + printf(" included from: '%s:%d'\n", + iter->name, iter->lineno-1); + iter = iter->parent; + } + if (iter) + printf(" included from: '%s:%d'\n", + iter->name, iter->lineno+1); + exit(1); + } } file->flags |= FILE_BUSY; file->lineno = 1; diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 3dbaec1..f23e3af 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -299,6 +299,7 @@ void zconf_initscan(const char *name) void zconf_nextfile(const char *name) { + struct file *iter; struct file *file = file_lookup(name); struct buffer *buf = malloc(sizeof(*buf)); memset(buf, 0, sizeof(*buf)); @@ -314,16 +315,24 @@ void zconf_nextfile(const char *name) buf->parent = current_buf; current_buf = buf; - if (file->flags & FILE_BUSY) { - printf("%s:%d: do not source '%s' from itself\n", - zconf_curname(), zconf_lineno(), name); - exit(1); - } - if (file->flags & FILE_SCANNED) { - printf("%s:%d: file '%s' is already sourced from '%s'\n", - zconf_curname(), zconf_lineno(), name, - file->parent->name); - exit(1); + for (iter = current_file->parent; iter; iter = iter->parent ) { + if (!strcmp(current_file->name,iter->name) ) { + printf("%s:%d: recursive inclusion detected. " + "Inclusion path:\n current file : '%s'\n", + zconf_curname(), zconf_lineno(), + zconf_curname()); + iter = current_file->parent; + while (iter && \ + strcmp(iter->name,current_file->name)) { + printf(" included from: '%s:%d'\n", + iter->name, iter->lineno-1); + iter = iter->parent; + } + if (iter) + printf(" included from: '%s:%d'\n", + iter->name, iter->lineno+1); + exit(1); + } } file->flags |= FILE_BUSY; file->lineno = 1;