From patchwork Thu Mar 22 17:00:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 132308 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1087668ljb; Thu, 22 Mar 2018 10:01:52 -0700 (PDT) X-Google-Smtp-Source: AG47ELuei27oVDqLnfsukYPuO2sxFJJRi3lCpSxQDK1k2kwOoutGfzFXFgZX2gHF1gOYtYeFWjqB X-Received: by 2002:a17:902:4001:: with SMTP id b1-v6mr3677300pld.273.1521738112680; Thu, 22 Mar 2018 10:01:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521738112; cv=none; d=google.com; s=arc-20160816; b=z0sOuD0vK6oPvkhZiO1F9sKxFOVkV/whYEV0tlkEztIB8VF+z+Ue67oeJvqG4/sqq+ cl73bvt6xATH9+YogiSxqS8EydKmGxYqmh+4cnZ9aiog7bfhbUXr4kWZjRBBJ1Bied37 v4AMR77BYnsj+T6PHLRshfBmX5b6mUsWneZrnny+B6p6feuZ0HdLhLgYoBx4l0KDrA/n E2dATAx6jk3MBxrXpupdNXRaJjZdueTRJPpEP4OE9uR9qbfMAAKH83Vn105lGAAwN4ZM mI0Qy5DbeUQkPRPfXgcJeMM3EY2aQtUdX8v8FVU4boUXDods6+S+qVFPUcEPvvmCwJwp fA8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter:arc-authentication-results; bh=6o5EADB16+/r+2A3psEaEYkm6g5BiCsyGcgmSzNLIC8=; b=QHPFCOcA9jHR+YP+CeSUz7OfsLu+q1uV3VhuX2c5pkoqSjUqkRTXYj9JKyMrpICYa1 8WsNIy03gU0J88yHsiouV2HtdIpewyyUxSsNq8tYoIrrcsPinek+cHqpLrMg7rQ3kdMw JzfaJMg+FNMA7ELmOtCtTod3RPyvF6p9dKAInAaInbunhBRRk7d76B99dDW3vnMVdZwe 1invA392U/UzpJEgD0zLqhR93zLfh549H0yE7GV1XJ8pyrjc7FUgSQxVrUScIRK6/3VD rtHxwv5hE0xlOGE4GwrX4TX/sKGTRSEXe64rRhVRgsFVYEYpVir7X6YTpm+CpnButgxZ tOVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=To7dO+eM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t13si4443387pgu.62.2018.03.22.10.01.22; Thu, 22 Mar 2018 10:01:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=To7dO+eM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751948AbeCVRBT (ORCPT + 28 others); Thu, 22 Mar 2018 13:01:19 -0400 Received: from conuserg-09.nifty.com ([210.131.2.76]:47772 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751898AbeCVRBQ (ORCPT ); Thu, 22 Mar 2018 13:01:16 -0400 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-09.nifty.com with ESMTP id w2MH0Mr2012430; Fri, 23 Mar 2018 02:00:22 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com w2MH0Mr2012430 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1521738023; bh=6o5EADB16+/r+2A3psEaEYkm6g5BiCsyGcgmSzNLIC8=; h=From:To:Cc:Subject:Date:From; b=To7dO+eM5igdFZv1Lt53HpwLO3xBf6Nse4kltYV8nLzT/msAs1QPtDWSdEzCQlNGa EQ3GZYZABUb4CHlnegPUXkSXpWn7A6H+9ZY8cwmBJd2Nb337dpQx4ugUcFkoIwmopU Oxe5G/7PBVZO3y2qUSrhIeRr9gcfNhxSft24zHqxnwwcFxtp/20F/+B6folUu6o7pf 1IBtlf0wFyYsMoYZb3g8fP7bGWPz1Bc7eqa4/H+eY76Mdvw1SlkRBUX4MgCISIdqXq TXyYCjPIHRSasmlT39E+f+xo82/5vpTOKNUis0MGwR5hInLkHYdFZtnALdJIK1G36E eRSOG7yi338ug== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Michal Marek , Sam Ravnborg , Ulf Magnusson , "Luis R . Rodriguez" , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 1/3] kconfig: remove duplicated file name and lineno of recursive inclusion Date: Fri, 23 Mar 2018 02:00:12 +0900 Message-Id: <1521738014-18895-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As in the unit test, the error message for the recursive inclusion looks like this: Kconfig.inc1:4: recursive inclusion detected. Inclusion path: current file : 'Kconfig.inc1' included from: 'Kconfig.inc3:1' included from: 'Kconfig.inc2:3' included from: 'Kconfig.inc1:4' The 'Kconfig.inc1:4' is duplicated in the first and last lines. Also, the single quotes do not help readability. Change the message like follows: Recursive inclusion detected. Inclusion path: current file : Kconfig.inc1 included from: Kconfig.inc3:1 included from: Kconfig.inc2:3 included from: Kconfig.inc1:4 Signed-off-by: Masahiro Yamada --- scripts/kconfig/tests/err_recursive_inc/expected_stderr | 11 ++++++----- scripts/kconfig/zconf.l | 9 ++++----- 2 files changed, 10 insertions(+), 10 deletions(-) -- 2.7.4 diff --git a/scripts/kconfig/tests/err_recursive_inc/expected_stderr b/scripts/kconfig/tests/err_recursive_inc/expected_stderr index a15dbed..6b582ee 100644 --- a/scripts/kconfig/tests/err_recursive_inc/expected_stderr +++ b/scripts/kconfig/tests/err_recursive_inc/expected_stderr @@ -1,5 +1,6 @@ -Kconfig.inc1:4: recursive inclusion detected. Inclusion path: - current file : 'Kconfig.inc1' - included from: 'Kconfig.inc3:1' - included from: 'Kconfig.inc2:3' - included from: 'Kconfig.inc1:4' +Recursive inclusion detected. +Inclusion path: + current file : Kconfig.inc1 + included from: Kconfig.inc3:1 + included from: Kconfig.inc2:3 + included from: Kconfig.inc1:4 diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 88b650e..6f139d2 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -328,14 +328,13 @@ void zconf_nextfile(const char *name) for (iter = current_file->parent; iter; iter = iter->parent ) { if (!strcmp(current_file->name,iter->name) ) { fprintf(stderr, - "%s:%d: recursive inclusion detected. " - "Inclusion path:\n current file : '%s'\n", - zconf_curname(), zconf_lineno(), - zconf_curname()); + "Recursive inclusion detected.\n" + "Inclusion path:\n" + " current file : %s\n", zconf_curname()); iter = current_file; do { iter = iter->parent; - fprintf(stderr, " included from: '%s:%d'\n", + fprintf(stderr, " included from: %s:%d\n", iter->name, iter->lineno - 1); } while (strcmp(iter->name, current_file->name)); exit(1); From patchwork Thu Mar 22 17:00:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 132310 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1087941ljb; Thu, 22 Mar 2018 10:02:02 -0700 (PDT) X-Google-Smtp-Source: AG47ELuwSGhz2mvSEc61ruEesqM1683BsQgcxVLum7j9Uf1Kqj4BthFouNTMlV5finbuqWyln+RG X-Received: by 2002:a17:902:1e5:: with SMTP id b92-v6mr14380066plb.78.1521738122724; Thu, 22 Mar 2018 10:02:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521738122; cv=none; d=google.com; s=arc-20160816; b=V/MP1zTySZSRIZvKfigDpXoGV9RBd27E0wVCjG3NkYQHI/YNHHopG/H9sJJOYvP4ZT w0RaLhhDOSohDg2ZnLmFoMGf7oEOn3eOiEIUQgMg5PI03U+mpM1EfRQkSLy6iezTsSBt pqTVY3XXItNeAigFRyv3boV0BCjgtnacnRKe/sRRLbBUxoaMWjOuqdW9Sc3Cjmox4y6L xSVgf1TMB5BT14Ee/PQ5NT/T3ZM0BjW1Nr2jHJ/uTYDgiCJRCniyfwMNzEFjwTORwKpt AN+STiyYCDCvTyoZVvqXNelNge2C1g6a4bf6VQsi4lCek9qMOq/Y3WAXqUDh5LBAwl0v 5nbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=6zVpC8ia9MmGsSQYMOG0Ae5Nm+HHA9lEhJv5gwvzIvI=; b=PMX4olgqmdOt8TEqCwzxVDLUUXHdjSPF4Eij5Zk2IYpObKszjCujjREYErFtonKAaI 6PQqPFBBk8AF3R47lfQXtIgJSP9RQRjZqJZTBDV98b4svUsCKlMSVC8gtiPd2xZBFDi7 pi5BeFC+qmXM+qbPMST/ITCxBczkpwtD8gcNqGgAiLDC/dV12WKm1hzKKRc1Muw29HNT BYyBhhQAy5umCE9O5QTZMd1FvJ/3lCcQ3om6vVffYxV6zWw1v46kMFEiBMxkxS7pQ5PJ r+K13oMYDL/DLLOILureSb5++QfBVedu96R+Shv9fiuvBMxdc/2GNejEMHersnvROb1V ApUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=DNtipiad; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t13si4443387pgu.62.2018.03.22.10.01.57; Thu, 22 Mar 2018 10:02:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=DNtipiad; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752025AbeCVRBe (ORCPT + 28 others); Thu, 22 Mar 2018 13:01:34 -0400 Received: from conuserg-09.nifty.com ([210.131.2.76]:47943 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751898AbeCVRBZ (ORCPT ); Thu, 22 Mar 2018 13:01:25 -0400 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-09.nifty.com with ESMTP id w2MH0Mr3012430; Fri, 23 Mar 2018 02:00:23 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com w2MH0Mr3012430 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1521738023; bh=6zVpC8ia9MmGsSQYMOG0Ae5Nm+HHA9lEhJv5gwvzIvI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DNtipiadzqYW06bMC+7pv8wag/scc3QcK3GZym3/DqR7U7Fu0nuPAcY0goQ+SvU50 nq5zxQZV7ZSKu4E5M25PQPXFVUNT5Na/15VQFY5/ZT819QzCA0ky6/wj88MED5fyMk gTNIUmo27mUp/wwJRxOR1BclxqomBpQHH2e/adOs/ti9GT2DBZ9leHsSDvxWHz+1iC pE4mSF6QIsEfmo1psIyvW/8V5ZBmMYIlXjnGkCTS9eIugQGr3C/7NwP1W//iFCyLAA c3gA4Z/dOap6/9jvUU1zQ6Hwx6Q+FKA9s/6eQ0ONr5q1k8h1Ww7gRDEpFm3HZ/I7St toxEvR2v20ftw== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Michal Marek , Sam Ravnborg , Ulf Magnusson , "Luis R . Rodriguez" , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 2/3] kconfig: detect recursive inclusion earlier Date: Fri, 23 Mar 2018 02:00:13 +0900 Message-Id: <1521738014-18895-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521738014-18895-1-git-send-email-yamada.masahiro@socionext.com> References: <1521738014-18895-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, the recursive inclusion is not detected when the offending file is about to be included; it is detected the offending file is about to include the *next* file. This is because the detection loop does not involve the file being included. Do this check against the file that is about to be included so that the recursive inclusion is detected before unneeded parsing happens. Signed-off-by: Masahiro Yamada --- scripts/kconfig/zconf.l | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) -- 2.7.4 diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 6f139d2..29b5d33 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -325,23 +325,25 @@ void zconf_nextfile(const char *name) buf->parent = current_buf; current_buf = buf; - for (iter = current_file->parent; iter; iter = iter->parent ) { - if (!strcmp(current_file->name,iter->name) ) { + file->parent = current_file; + + for (iter = current_file; iter; iter = iter->parent) { + if (!strcmp(iter->name, file->name)) { fprintf(stderr, "Recursive inclusion detected.\n" "Inclusion path:\n" - " current file : %s\n", zconf_curname()); - iter = current_file; + " current file : %s\n", file->name); + iter = file; do { iter = iter->parent; fprintf(stderr, " included from: %s:%d\n", iter->name, iter->lineno - 1); - } while (strcmp(iter->name, current_file->name)); + } while (strcmp(iter->name, file->name)); exit(1); } } + file->lineno = 1; - file->parent = current_file; current_file = file; } From patchwork Thu Mar 22 17:00:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 132309 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1087824ljb; Thu, 22 Mar 2018 10:01:57 -0700 (PDT) X-Google-Smtp-Source: AG47ELuBK+NikEaMP0aMDyxRKQOGd5olG0p7svu11CvhYGVeohTHnaub+mPdV1GuTrZLzGA77LNP X-Received: by 10.99.100.132 with SMTP id y126mr18114189pgb.77.1521738117470; Thu, 22 Mar 2018 10:01:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521738117; cv=none; d=google.com; s=arc-20160816; b=sn88f6jo6lP4B8ffPKrQHknkcSkkY+ETBO8zhe8Xe/65g5ibVgKsp9Ssqkv3E2CaqW jw/453TT2gWV7pdoMg1z0RX0TYOVq09Hy8jIqmpSeRRg/5WF7VKfwSnS1/ot0WGlQ24m Ky988nvtadJO4x9bubUId0ec8WDY5jJE0CWzj0WdBSbMzaHWXa482lb0raJwHgqfcSKS L8ET95eeuRKv/lBraC2RYEDuGgFJXuIukRwXJa0DyNxX/1+1kaWb72XKxA5OlR7SL3dD 9TC/2rXea65H9S+IqGa4F1Zs08UFOyRwnfF5jiQ64+R3KiOV1J5DY+Tk/YDn7MgXQ8iF AGnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=TdM89TA/Crj305aRLV39gwF6+e1O4YlkyNvavNN2Z3c=; b=H6vxFUfp1pIFQgyrB+/jMxZcGTgzazGdEARNQDG95gBJqJXzZtak2d5mK+x9MDyXKR 88Ypn0VjSOKGPJmx1gXeI98EHGxKU+tcwnJZPf/Rq1YjUelDpqynHRttVap2rImoortM lJ0EiZOlFo7gXdtB66kK0dyObgDC7pZmnNskKx8I7adCX3Xh9ytGzL5ryozKH4+bCH49 PfxSvSBzQTtEQLwDOio2xPspxHqdA/1fxB1XbOsQEFsexqoYD17mYJnvKd6gz8aYVs4U +2pkWZ2yhtJGvPFUS9vZYe6AaeXxkAhnqXLCwzGG2JsyEP+585mA35GjbXyIFaKspB3M +5qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=1kxetWus; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t13si4443387pgu.62.2018.03.22.10.01.53; Thu, 22 Mar 2018 10:01:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=1kxetWus; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752001AbeCVRBa (ORCPT + 28 others); Thu, 22 Mar 2018 13:01:30 -0400 Received: from conuserg-09.nifty.com ([210.131.2.76]:47944 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751758AbeCVRBZ (ORCPT ); Thu, 22 Mar 2018 13:01:25 -0400 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-09.nifty.com with ESMTP id w2MH0Mr4012430; Fri, 23 Mar 2018 02:00:23 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com w2MH0Mr4012430 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1521738024; bh=TdM89TA/Crj305aRLV39gwF6+e1O4YlkyNvavNN2Z3c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1kxetWuscPsDO0UOsJWs6vYow8Wv/oTBssrelKwDQ506XjV1c1gdVcslRnYD5WBPh T9Z74U2AuNfRoiBMfYIGmmzKFZPksKY/RKYVudtdBfu7YtvxnRRO4H9gvKPJ56jISX Vnz4vl1qd5ozF6Yuo32+qqR0zLM0L5YptOivBhv4y0z0o1pHkRMLpawfxHnOOA/lAk YGWhe/6/7D9R084V/+h+NLGCKe9vSXnygdLymeBvzpIRzfNeMqbCKAkxLug4w1ez9P giPy4x9Ga3OkBFjeF7ijJYfxYPXWIe92AI6J4Fx1YxLbKC7HWHYiQDU/8/CPxw6YZx POcVHsjK5ecAw== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Michal Marek , Sam Ravnborg , Ulf Magnusson , "Luis R . Rodriguez" , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 3/3] kconfig: use yylineno option instead of manual lineno increments Date: Fri, 23 Mar 2018 02:00:14 +0900 Message-Id: <1521738014-18895-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521738014-18895-1-git-send-email-yamada.masahiro@socionext.com> References: <1521738014-18895-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Tracking the line number by hand is error-prone since we need to make sure to increment it in all the \n matching patterns. If '%option yylineno' is set, flex defines 'yylineno' to contain the current line number and automatically updates it each time it reads a \n character. This is much more convenient although the lexer does not initializes yylineno, so you need to set it to 1 each time you start reading a new file, and restore it you go back to the previous file. I tested this with DEBUG_PARSE, and confirmed the same dump message was produced. I removed the perf-report option. Otherwise, I see the following message: %option yylineno entails a performance penalty ONLY on rules that can match newline characters Signed-off-by: Masahiro Yamada --- scripts/kconfig/lkc.h | 1 + scripts/kconfig/zconf.l | 20 +++++++++----------- 2 files changed, 10 insertions(+), 11 deletions(-) -- 2.7.4 diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 2d5ec2d..f4394af 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -68,6 +68,7 @@ struct kconf_id { enum symbol_type stype; }; +extern int yylineno; void zconfdump(FILE *out); void zconf_starthelp(void); FILE *zconf_fopen(const char *name); diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 29b5d33..045093d 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -1,5 +1,5 @@ %option nostdinit noyywrap never-interactive full ecs -%option 8bit nodefault perf-report perf-report +%option 8bit nodefault yylineno %option noinput %x COMMAND HELP STRING PARAM %{ @@ -83,7 +83,6 @@ n [A-Za-z0-9_-] [ \t]*#.*\n | [ \t]*\n { - current_file->lineno++; return T_EOL; } [ \t]*#.* @@ -104,7 +103,7 @@ n [A-Za-z0-9_-] const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); BEGIN(PARAM); current_pos.file = current_file; - current_pos.lineno = current_file->lineno; + current_pos.lineno = yylineno; if (id && id->flags & TF_COMMAND) { yylval.id = id; return id->token; @@ -116,7 +115,6 @@ n [A-Za-z0-9_-] . warn_ignored_character(*yytext); \n { BEGIN(INITIAL); - current_file->lineno++; return T_EOL; } } @@ -138,7 +136,7 @@ n [A-Za-z0-9_-] new_string(); BEGIN(STRING); } - \n BEGIN(INITIAL); current_file->lineno++; return T_EOL; + \n BEGIN(INITIAL); return T_EOL; ({n}|[/.])+ { const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); if (id && id->flags & TF_PARAM) { @@ -150,7 +148,7 @@ n [A-Za-z0-9_-] return T_WORD; } #.* /* comment */ - \\\n current_file->lineno++; + \\\n ; [[:blank:]]+ . warn_ignored_character(*yytext); <> { @@ -187,7 +185,6 @@ n [A-Za-z0-9_-] fprintf(stderr, "%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno()); - current_file->lineno++; BEGIN(INITIAL); return T_EOL; } @@ -220,12 +217,10 @@ n [A-Za-z0-9_-] } } [ \t]*\n/[^ \t\n] { - current_file->lineno++; zconf_endhelp(); return T_HELPTEXT; } [ \t]*\n { - current_file->lineno++; append_string("\n", 1); } [^ \t\n].* { @@ -304,7 +299,7 @@ void zconf_initscan(const char *name) memset(current_buf, 0, sizeof(*current_buf)); current_file = file_lookup(name); - current_file->lineno = 1; + yylineno = 1; } void zconf_nextfile(const char *name) @@ -325,6 +320,7 @@ void zconf_nextfile(const char *name) buf->parent = current_buf; current_buf = buf; + current_file->lineno = yylineno; file->parent = current_file; for (iter = current_file; iter; iter = iter->parent) { @@ -343,7 +339,7 @@ void zconf_nextfile(const char *name) } } - file->lineno = 1; + yylineno = 1; current_file = file; } @@ -352,6 +348,8 @@ static void zconf_endfile(void) struct buffer *parent; current_file = current_file->parent; + if (current_file) + yylineno = current_file->lineno; parent = current_buf->parent; if (parent) {