all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alex <agrambot@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 5624@debbugs.gnu.org, user42@zip.com.au
Subject: bug#5624: 23.1; etags elisp and scheme "=" in names
Date: Sun, 11 Jun 2017 20:44:29 -0600	[thread overview]
Message-ID: <87shj553hu.fsf@gmail.com> (raw)
In-Reply-To: <83poea60fz.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 11 Jun 2017 17:52:48 +0300")

[-- Attachment #1: Type: text/plain, Size: 1233 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Alex <agrambot@gmail.com>
>> 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.



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: notinname_lang --]
[-- Type: text/x-diff, Size: 3126 bytes --]

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);

  reply	other threads:[~2017-06-12  2:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-22 22:09 bug#5624: 23.1; etags elisp and scheme "=" in names Kevin Ryde
2017-06-11  1:37 ` Alex
2017-06-11 14:52   ` Eli Zaretskii
2017-06-12  2:44     ` Alex [this message]
2017-06-12 14:13       ` Eli Zaretskii
2017-06-13  3:31         ` Alex
2017-06-13 14:28           ` Eli Zaretskii
2017-06-14 22:10             ` Alex
2017-07-08  8:28               ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87shj553hu.fsf@gmail.com \
    --to=agrambot@gmail.com \
    --cc=5624@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=user42@zip.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.