Skip to content

Commit

Permalink
Don't save deleted lines to (default) register.
Browse files Browse the repository at this point in the history
Previously, after deleting lines, they could be restored from the
default register, e.g.,

$ ed -p '*'
*a
hello
world
.
*1d
*,p
world
*<t0
*,p
hello
world
*

Since this adds significant overhead, it has been disabled by default.
To restore the old behavior, define CFLAGS macro WANT_ED_REGISTER_DELETE,
e.g.,

./configure --enable-all-extensions CFLAGS=-DWANT_ED_REGISTER_DELETE
  • Loading branch information
slewsys committed Jan 20, 2025
1 parent 9f848dd commit 15411e8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 0 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,7 @@ AM_GNU_GETTEXT_VERSION([0.21])
AX_CHECK_OPENSSL([ac_cv_have_openssl='yes'])

AC_FUNC_FORK
AC_FUNC_VFORK
AC_FUNC_FSEEKO
AC_PROG_GCC_TRADITIONAL

# NB: malloc.c from GNU libc is problematic, e.g., for cross-compiling
AC_FUNC_MALLOC
Expand Down
4 changes: 2 additions & 2 deletions src/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,15 +441,15 @@ d_cmd (ed_buffer_t *ed)
if ((status = is_valid_range (ed->state->dot, ed->state->dot, ed)) < 0)
return status;

#ifdef WANT_ED_REGISTER
#ifdef WANT_ED_REGISTER_DELETE
/* Save deleted lines in default register. */
ed->core->regbuf->io_f |= REGISTER_WRITE;
ed->core->regbuf->write_idx = REGBUF_MAX - 1;
#endif
COMMAND_SUFFIX (ed->display->io_f, ed);
if (!ed->exec->global)
reset_undo_queue (ed);
#ifdef WANT_ED_REGISTER
#ifdef WANT_ED_REGISTER_DELETE
if ((status = append_to_register (ed->exec->region->start,
ed->exec->region->end, 0, ed)) < 0)
return status;
Expand Down

0 comments on commit 15411e8

Please sign in to comment.