From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alex Newsgroups: gmane.emacs.bugs Subject: bug#5624: 23.1; etags elisp and scheme "=" in names Date: Sun, 11 Jun 2017 20:44:29 -0600 Message-ID: <87shj553hu.fsf@gmail.com> References: <87eikcrkg8.fsf@blah.blah> <878tkztic2.fsf@gmail.com> <83poea60fz.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1497235515 28640 195.159.176.226 (12 Jun 2017 02:45:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 12 Jun 2017 02:45:15 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) Cc: 5624@debbugs.gnu.org, user42@zip.com.au To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jun 12 04:45:11 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKFLr-00074r-3V for geb-bug-gnu-emacs@m.gmane.org; Mon, 12 Jun 2017 04:45:11 +0200 Original-Received: from localhost ([::1]:35852 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKFLt-0002WK-AM for geb-bug-gnu-emacs@m.gmane.org; Sun, 11 Jun 2017 22:45:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57834) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKFLm-0002V6-Nk for bug-gnu-emacs@gnu.org; Sun, 11 Jun 2017 22:45:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dKFLi-0008Vx-Nv for bug-gnu-emacs@gnu.org; Sun, 11 Jun 2017 22:45:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:38995) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dKFLi-0008Vt-Jk for bug-gnu-emacs@gnu.org; Sun, 11 Jun 2017 22:45:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dKFLi-0004YV-Dq for bug-gnu-emacs@gnu.org; Sun, 11 Jun 2017 22:45:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alex Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 12 Jun 2017 02:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 5624 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 5624-submit@debbugs.gnu.org id=B5624.149723548317466 (code B ref 5624); Mon, 12 Jun 2017 02:45:02 +0000 Original-Received: (at 5624) by debbugs.gnu.org; 12 Jun 2017 02:44:43 +0000 Original-Received: from localhost ([127.0.0.1]:41672 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKFLO-0004Xe-Ux for submit@debbugs.gnu.org; Sun, 11 Jun 2017 22:44:43 -0400 Original-Received: from mail-it0-f46.google.com ([209.85.214.46]:36920) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKFLN-0004XR-Oy for 5624@debbugs.gnu.org; Sun, 11 Jun 2017 22:44:42 -0400 Original-Received: by mail-it0-f46.google.com with SMTP id m47so15588829iti.0 for <5624@debbugs.gnu.org>; Sun, 11 Jun 2017 19:44:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=+EdbSl0pYMTgNntXrxiioOyVFZ0YQml/IeoZfZCJQOE=; b=g6n3Vo408MND6SwEV8qJ8RIXv0WywvSSpJZzgWfEVv5d0koW+3+gJXlWu5ttldHQLT s3ix+wTAeQMS8KG78SZJdkRIDIWANCZDPfODzLme8yXmKAqqxFJQqlwUSJz2vM5uJin3 w4DJ72bM0kDJaXItAGXQ6qxcTBpNa0hR6LQeuDQFNmf3VQF+8L862S6DIuRsmHpVkEdT iZNFUQVA90Vk2kSxbGN28o8/UXVbZO7cfcWxA6zPfJK0MRb7xO2Ae/d2FcFniXQJp9nt 4v9DAWv1K/pk/VY8gL14pMboKNtgVz+Y46d9ejHwwS99NCz9IyHvchTzMm7Vy5p+A0yO Az6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=+EdbSl0pYMTgNntXrxiioOyVFZ0YQml/IeoZfZCJQOE=; b=DZ6CUSVatB356YP1r5ZTq0sBNJJ3Qav4Grm6dUaXIdf8DlAMwcfRwAeJorCUJ2EXAl NZXVQg5m+sU1F96Wy8IpT5SatclTqVPtDiVeNHvl8hafLEHCfFFhTKicGMsbu88IWHml 9ecA0o9o56FbitktNmrzJjOJ5qbUU5EP8utmc6rwUO7SN/2uRzedjs3avpX5biYDiB2N GNJsOVp4ae9LaVj8IxqU2RUMC9esCgQebhdHQuzfGY+kU9my6CRdBwYNDpHxp/aDONV4 7ouk+D9nEBM+MX7EZvBx/vw4M1mePaIRFtrKojO7VGRWwJtkp0Rrq1cXz1PLpQPsIm5F kksA== X-Gm-Message-State: AODbwcDOKOcPLsbO7EzweVg/O5FdM6DYRaiy70iFUBPcCCsyOJ6a5/2I 2OWYanhlUffeX+iK X-Received: by 10.36.69.19 with SMTP id y19mr9805238ita.26.1497235475745; Sun, 11 Jun 2017 19:44:35 -0700 (PDT) Original-Received: from lylat (S010664777d9cebe3.ss.shawcable.net. [70.64.85.59]) by smtp.gmail.com with ESMTPSA id h76sm3485982ith.24.2017.06.11.19.44.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 11 Jun 2017 19:44:34 -0700 (PDT) In-Reply-To: <83poea60fz.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 11 Jun 2017 17:52:48 +0300") 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: 208.118.235.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:133489 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: Alex >> Date: Sat, 10 Jun 2017 19:37:49 -0600 >> Cc: 5624@debbugs.gnu.org >> This appears to be because in etags.c, all languages use the same >> `notinname' procedure to determine a valid identifier. > > Yes. But there are exceptions from this rule, where that is deemed > necessary. For example, Ruby_functions has this: > > /* Ruby method names can end in a '='. Also, operator overloading can > define operators whose names include '='. */ > while (!notinname (*cp) || *cp == '=') > cp++; > >> Shouldn't each language (optionally) use a different procedure to >> determine the bounds of an identifier? Lisp and Scheme, for instance, >> would not have '=' in their respective `notinname' procedures. > > Feel free to work on this, if you want to scratch that particular > itch. Alternatively, just augment notinname in language-specific > support code, like some of the supported languages already do. > > TIA. One issue is that the Lisp and Scheme functions use get_tag, which uses notinname. What do you think about the following diff? It adds a wrapper to notinname which get_tag uses. I had to add an additional parameter to get_tag. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=etags.diff Content-Description: notinname_lang diff --git a/lib-src/etags.c b/lib-src/etags.c index 6f280d8ab4..e354325ad5 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c @@ -181,6 +181,20 @@ notinname (unsigned char c) return table[c]; } +/* C is not in a name in language LANG. */ +static bool +notinname_lang (unsigned char c, char const *lang) +{ + if (lang == NULL) + return notinname (c); + + else if (streq ("lisp", lang) || streq ("scheme", lang)) + if (c == '=') + return false; + + return notinname (c); +} + /* C can start a token. */ static bool begtoken (unsigned char c) @@ -371,7 +385,7 @@ static language *get_language_from_langname (const char *); static void readline (linebuffer *, FILE *); static long readline_internal (linebuffer *, FILE *, char const *); static bool nocase_tail (const char *); -static void get_tag (char *, char **); +static void get_tag (char *, char **, char const *); static void analyze_regex (char *); static void free_regexps (void); @@ -4715,7 +4729,7 @@ Perl_functions (FILE *inf) if (LOOKING_AT (cp, "package")) { free (package); - get_tag (cp, &package); + get_tag (cp, &package, NULL); } else if (LOOKING_AT (cp, "sub")) { @@ -5346,7 +5360,7 @@ L_getit (void) /* Ok, then skip "(" before name in (defstruct (foo)) */ dbp = skip_spaces (dbp); } - get_tag (dbp, NULL); + get_tag (dbp, NULL, "lisp"); } static void @@ -5426,7 +5440,7 @@ Lua_functions (FILE *inf) { char *tag_name, *tp_dot, *tp_colon; - get_tag (bp, &tag_name); + get_tag (bp, &tag_name, NULL); /* If the tag ends with ".foo" or ":foo", make an additional tag for "foo". */ tp_dot = strrchr (tag_name, '.'); @@ -5436,7 +5450,7 @@ Lua_functions (FILE *inf) char *p = tp_dot > tp_colon ? tp_dot : tp_colon; int len_add = p - tag_name + 1; - get_tag (bp + len_add, NULL); + get_tag (bp + len_add, NULL, NULL); } } } @@ -5468,7 +5482,7 @@ PS_functions (FILE *inf) lb.buffer, ep - lb.buffer + 1, lineno, linecharno); } else if (LOOKING_AT (bp, "defineps")) - get_tag (bp, NULL); + get_tag (bp, NULL, NULL); } } @@ -5550,12 +5564,12 @@ Scheme_functions (FILE *inf) bp = skip_non_spaces (bp+4); /* Skip over open parens and white space. Don't continue past '\0'. */ - while (*bp && notinname (*bp)) + while (*bp && notinname_lang (*bp, "scheme")) bp++; - get_tag (bp, NULL); + get_tag (bp, NULL, "scheme"); } if (LOOKING_AT (bp, "(SET!") || LOOKING_AT (bp, "(set!")) - get_tag (bp, NULL); + get_tag (bp, NULL, "scheme"); } } @@ -6573,14 +6587,14 @@ nocase_tail (const char *cp) } static void -get_tag (register char *bp, char **namepp) +get_tag (register char *bp, char **namepp, char const *lang) { register char *cp = bp; if (*bp != '\0') { /* Go till you get to white space or a syntactic break */ - for (cp = bp + 1; !notinname (*cp); cp++) + for (cp = bp + 1; !notinname_lang (*cp, lang); cp++) continue; make_tag (bp, cp - bp, true, lb.buffer, cp - lb.buffer + 1, lineno, linecharno); --=-=-=--