Function: re--describe-compiled

re--describe-compiled is a function defined in search.c.

Signature

(re--describe-compiled REGEXP &optional RAW)

Documentation

Return a string describing the compiled form of REGEXP.

If RAW is non-nil, just return the actual bytecode.

View in manual

Source Code

// Defined in /usr/src/emacs/src/search.c
{
  CHECK_STRING (regexp);
  struct regexp_cache *cache_entry
    = compile_pattern (regexp, NULL,
                       (!NILP (Vcase_fold_search)
                        ? BVAR (current_buffer, case_canon_table) : Qnil),
                       false,
                       !NILP (BVAR (current_buffer,
                                    enable_multibyte_characters)));
  if (!NILP (raw))
    return make_unibyte_string ((char *) cache_entry->buf.buffer,
                                cache_entry->buf.used);
  else
    {                           /* FIXME: Why ENABLE_CHECKING?  */
#if !defined ENABLE_CHECKING
      error ("Not available: rebuild with --enable-checking");
#elif HAVE_OPEN_MEMSTREAM
      char *buffer = NULL;
      size_t size = 0;
      FILE* f = open_memstream (&buffer, &size);
      if (!f)
        report_file_error ("open_memstream failed", regexp);
      print_compiled_pattern (f, &cache_entry->buf);
      fclose (f);
      if (!buffer)
        return Qnil;
      Lisp_Object description = make_unibyte_string (buffer, size);
      free (buffer);
      return description;
#else /* ENABLE_CHECKING && !HAVE_OPEN_MEMSTREAM */
      print_compiled_pattern (stderr, &cache_entry->buf);
      return build_string ("Description was sent to standard error");
#endif /* !ENABLE_CHECKING */
    }
}