unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: emacs-devel@gnu.org
Subject: Re: Limits on the regexp string length
Date: Wed, 21 Dec 2022 15:39:27 +0200	[thread overview]
Message-ID: <83zgbganao.fsf@gnu.org> (raw)
In-Reply-To: <87h6xox6m8.fsf@localhost> (message from Ihor Radchenko on Wed, 21 Dec 2022 12:51:11 +0000)

> From: Ihor Radchenko <yantar92@posteo.net>
> Date: Wed, 21 Dec 2022 12:51:11 +0000
> 
> It looks like the length of regular expressions in Emacs is limited and
> regexps exceeding this length cause error being thrown: "Regular
> expression too big".
> 
> Is there any rationale behind this limit? Can we increase it somehow
> from Elisp?

See this part of regex-emacs.c:

  /* This is not an arbitrary limit: the arguments which represent offsets
     into the pattern are two bytes long.  So if 2^15 bytes turns out to
     be too small, many things would have to change.  */
  # define MAX_BUF_SIZE (1 << 15)

  /* Extend the buffer by at least N bytes via realloc and
     reset the pointers that pointed into the old block to point to the
     correct places in the new one.  If extending the buffer results in it
     being larger than MAX_BUF_SIZE, then flag memory exhausted.  */
  #define EXTEND_BUFFER(n)						\
    do {								\
      ptrdiff_t requested_extension = n;				\
      unsigned char *old_buffer = bufp->buffer;				\
      if (MAX_BUF_SIZE - bufp->allocated < requested_extension)		\
	return REG_ESIZE;						\




      reply	other threads:[~2022-12-21 13:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-21 12:51 Limits on the regexp string length Ihor Radchenko
2022-12-21 13:39 ` Eli Zaretskii [this message]

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=83zgbganao.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=yantar92@posteo.net \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).