emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Limits on the regexp string length


From: Eli Zaretskii
Subject: Re: Limits on the regexp string length
Date: Wed, 21 Dec 2022 15:39:27 +0200

> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]