all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Derek Peschel <dpeschel@eskimo.com>
To: bug-gnu-emacs@gnu.org
Subject: Etags (Emacs 22.2) -- miscompiles multiline user regexes
Date: Thu, 17 Apr 2008 12:23:25 -0700	[thread overview]
Message-ID: <20080417122325.A29387@eskimo.com> (raw)

When using etags's --regex option and the m modifier after the expression,
I've been seeing one of two things:

  - etags complains about an unterminated [ or [^, or unmatched \(,
    even though the expression is well-formed

  - etags doesn't complain but the expression matches more lines than
    it should (e.g. an expression ending with the literal text ___P
    also matches lines containing ___ and any other letter)

These happen whether or not the expression has a name subexpression.
Finally I realized one bug might cause both behaviors: not scanning the
entire tag subexpression, but instead omitting the last character from
the scan.  Adding a space after the tag subexpression on the command line
fixes the error or produces the proper number of matches.

Editing regex.c to set debug to a positive value, and recompiling with
DEBUG defined, shows that the compiled text is indeed too short.  Probably
this line in add_regex (in etags.c) is the cause:

  err = re_compile_pattern (pat, strlen (regexp_pattern), patbuf);

Notice how pat is passed as the string but the length of regexp_pattern
(not pat) is passed.  And because of the concat a few lines above,
the two strings differ in length by one character when the m modifier
is used.

Incidentally, regex.c mentions iregex.c and main.c but those files don't
seem to be distributed with etags.  They might have made this problem
easier to find.

Let me know if you have questions or want test cases.

-- Derek




                 reply	other threads:[~2008-04-17 19:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20080417122325.A29387@eskimo.com \
    --to=dpeschel@eskimo.com \
    --cc=bug-gnu-emacs@gnu.org \
    /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.