From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Skip Montanaro Newsgroups: gmane.emacs.bugs Subject: bug#38511: etags seems to be confused by macros Date: Mon, 9 Dec 2019 06:39:33 -0600 Message-ID: References: <83sglwfvz4.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="52930"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 38511@debbugs.gnu.org To: Francesco =?UTF-8?Q?Potort=C3=AC?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Dec 09 13:41:24 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ieILs-000Ddu-4D for geb-bug-gnu-emacs@m.gmane.org; Mon, 09 Dec 2019 13:41:24 +0100 Original-Received: from localhost ([::1]:39360 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieILq-0002Ms-A5 for geb-bug-gnu-emacs@m.gmane.org; Mon, 09 Dec 2019 07:41:22 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34903) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieILY-0002Me-Q4 for bug-gnu-emacs@gnu.org; Mon, 09 Dec 2019 07:41:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ieILW-0004gI-Ez for bug-gnu-emacs@gnu.org; Mon, 09 Dec 2019 07:41:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46767) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ieILV-0004g4-TA for bug-gnu-emacs@gnu.org; Mon, 09 Dec 2019 07:41:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ieILV-0000eD-Ra for bug-gnu-emacs@gnu.org; Mon, 09 Dec 2019 07:41:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Skip Montanaro Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 09 Dec 2019 12:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38511 X-GNU-PR-Package: emacs Original-Received: via spool by 38511-submit@debbugs.gnu.org id=B38511.15758952062410 (code B ref 38511); Mon, 09 Dec 2019 12:41:01 +0000 Original-Received: (at 38511) by debbugs.gnu.org; 9 Dec 2019 12:40:06 +0000 Original-Received: from localhost ([127.0.0.1]:52740 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ieIKc-0000co-HY for submit@debbugs.gnu.org; Mon, 09 Dec 2019 07:40:06 -0500 Original-Received: from mail-pf1-f175.google.com ([209.85.210.175]:36607) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ieIKb-0000c9-OC for 38511@debbugs.gnu.org; Mon, 09 Dec 2019 07:40:06 -0500 Original-Received: by mail-pf1-f175.google.com with SMTP id x184so5740973pfb.3 for <38511@debbugs.gnu.org>; Mon, 09 Dec 2019 04:40:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=CJc+jhXVNXpStFNMxyp9X74cRqmKhOEjAGlzVmCQYY4=; b=qafY/w9k2aaRFQlRatZc+VqKyArwcVfPIBK/cMLH7KGhYDKkKcyQYqnH1nhHjk2xVy d4NLjwDCJn+ncjwCQrI0ac+ywMdeH7jsqx1obIG0wA+X1cncE6KT/A5iqSrQRPrjOuia CfxuiHasfqLUsK1kI8ygU3vJ8/krMJfuP4QSeyMSEyIT+14bNVxz6nsqPIdPstQfhJQF EPcbPCWBFuU/nSf231vNf6FXsVwPiiyTPhc+QgtOtWqO8UGHgY5ebfsV9Vl9+n4naIQJ WE5mzMXAac5QL5CeMdXZWtx5tR4GMpr7SvrPLRONdMVALSm0g8weGnvjr5KSWBv3aPra JHRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=CJc+jhXVNXpStFNMxyp9X74cRqmKhOEjAGlzVmCQYY4=; b=N4Gg93VnIGfUcBcQIKCbAI1E432jOk7K68/bJqIIPpRPLb/QpLGoEZymFLQ/xtb3fJ FedGSMsfyUULuIK9m5PNjAG85C2ZlrTLnU6oFVUEiJ1TzE+RqcHwDsDqe0yFE1QyCq1s ej9wj44nEkMabrEEW+OlvO/G8PdsV1H3oGZ0ywmCSqDgM19sfQRPKI9hNcDzaMpPcW0+ o8XW8qvsl359Crpx2g9EkKetyleJhO3g51Zn/DYrWLvKeV0UdkVbieJPDIky5yg3cOCL tQi2xsuvQmzaLYW2TACyBazIzBPoJ/wtvtMANpJ13KY2dlcWhYZOEB/UuAo6+bAcuAZO t48Q== X-Gm-Message-State: APjAAAXYX05Uk3T5xANyzwbYc2/zuP5CcZ2TSv9J5GN7sIfhzYj/fosp pw4IHSgShtl1MlDxHz9tEOvSsY8oP38wb+0KOG3RXWAJv81PfIA= X-Google-Smtp-Source: APXvYqx/cUgjL03dD0ow3IgY3ECRjYO391WHUoF6ET5WYQe29aASItTNtdqGSPwJ+RNqgLYB1ef29D9o2b1Vg2NGjaU= X-Received: by 2002:a65:4506:: with SMTP id n6mr18623783pgq.105.1575895199615; Mon, 09 Dec 2019 04:39:59 -0800 (PST) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:173100 Archived-At: > Eli Zaretskii: > Etags works by looking at the source at face value, and it doesn't > expand macros as a C compiler would. So this: > > Py_LOCAL_INLINE(void) stackdepth_push(basicblock ***sp, basicblock *b, i= nt depth) > > looks to its na=C3=AFve lexical analysis very much like a K&R definition = of > a function and declaration of its arguments: ... > Patches are welcome, if someone has an idea for how to fix that. > Franceso: > Unless some C code wizard steps up and contradicts me, I'd say that it > is in principle impossible for Etags to detect such macros. This is a > work for the --regex feature of Etags, which is thought just for this > sort of situations. > > The Etags man page explains it with examples, as does the info page. I read the documentation and didn't understand how the regex feature would help. It seems to be useful to identify other constructs which you'd like tagged (such as the DEFVAR macro in the Emacs source), not transform the source in some way. Put another way, I need a "find/replace" sort of feature, not just a "find" feature. FWIW, here's the simple shell script I came up with: #!/bin/bash # etags gets confused by Python's use of the Py_LOCAL and Py_LOCAL_INLINE # macros to select compiler-dependent static storage syntax. This script is # a stand-in for etags which performs the macro expansion manually, then # pipes the result to etags. $@ are the args to pass to etags. sed -E -e 's/Py_LOCAL_INLINE *\(([^(]+)\)/static inline \1/' \ -e 's/Py_LOCAL *\(([^(]+)\)/static \1/' \ | etags "$@" I set speedbar-fetch-etags-command to that script. Seems to work well enough for my needs. It clearly isn't a general solution though. I suppose I could try to run the source through cpp, though I don't know if etags is smart enough to use the "# " output of cpp. I'll take a look at etags.c, but don't hold your breath waiting for a miracle. :-) Skip