summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2021-10-19 16:12:42 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2021-10-19 16:12:42 +0900
commitae28df49e293e060f1f58a1c2ad07dee829042e4 (patch)
tree7f52a2bc24a1539ea0fc9db89d5aab35ab0700aa
parenta95df6d374a9be6fa8cee82be6ff1fb51a3c8593 (diff)
downloaded-ae28df49e293e060f1f58a1c2ad07dee829042e4.tar.gz
ed-ae28df49e293e060f1f58a1c2ad07dee829042e4.tar.bz2
ed-ae28df49e293e060f1f58a1c2ad07dee829042e4.zip
Imported Upstream version 1.11upstream/1.11
-rw-r--r--AUTHORS2
-rw-r--r--COPYING6
-rw-r--r--ChangeLog84
-rw-r--r--INSTALL45
-rw-r--r--Makefile.in72
-rw-r--r--NEWS25
-rw-r--r--README53
-rw-r--r--TODO14
-rw-r--r--buffer.c9
-rw-r--r--carg_parser.c42
-rw-r--r--carg_parser.h19
-rwxr-xr-xconfigure139
-rw-r--r--doc/ed.129
-rw-r--r--doc/ed.info708
-rw-r--r--doc/ed.texi (renamed from doc/ed.texinfo)184
-rw-r--r--doc/fdl.texi (renamed from doc/fdl.texinfo)0
-rw-r--r--ed.h5
-rw-r--r--global.c8
-rw-r--r--io.c24
-rw-r--r--main.c32
-rw-r--r--main_loop.c20
-rw-r--r--regex.c5
-rw-r--r--signal.c25
-rwxr-xr-xtestsuite/check.sh48
-rw-r--r--testsuite/e1.r3
-rw-r--r--testsuite/e1.t2
-rw-r--r--testsuite/r3.r1
27 files changed, 831 insertions, 773 deletions
diff --git a/AUTHORS b/AUTHORS
index df41f2b..26c3a0f 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -11,7 +11,7 @@ provided by François Pinard.
GNU ed THANKS file - last updated on 15 November 1994.
GNU ed originated with the editor algorithm from Brian W. Kernighan &
-P. J. Plauger's wonderful book "Software Tools in Pascal," Addison-Wesley,
+P. J. Plauger's wonderful book "Software Tools in Pascal", Addison-Wesley,
1981. GNU ed has also benefitted from the contributions of numerous people
who reported problems, suggested various improvements or submitted actual
code. Among these are the following:
diff --git a/COPYING b/COPYING
index 4432540..b27ad83 100644
--- a/COPYING
+++ b/COPYING
@@ -1,4 +1,3 @@
-
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
@@ -77,7 +76,7 @@ modification follow.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
-
+
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
@@ -510,7 +509,7 @@ actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
-
+
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
@@ -673,4 +672,3 @@ may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
-
diff --git a/ChangeLog b/ChangeLog
index 52f2795..bc44e75 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,20 +1,57 @@
+2015-03-30 Antonio Diaz Diaz <antonio@gnu.org>
+
+ * Version 1.11 released.
+ * main_loop.c (exec_command): Fixed 'z' command.
+ (zN printed N + 1 lines).
+ * ed.texi: Documented the window size used by the 'z' command.
+ * Makefile.in: Added new targets 'install*-compress'.
+ * Restored original copyright notices in the code. I assigned to
+ the FSF the copyright on changes made to the part of ed already
+ copyrighted by the FSF, which seems to be just the manual.
+
+2014-01-22 Antonio Diaz Diaz <antonio@gnu.org>
+
+ * Version 1.10 released.
+ * ed.texinfo: Renamed to ed.texi.
+
+2013-06-18 Antonio Diaz Diaz <antonio@gnu.org>
+
+ * Version 1.9 released.
+ * check.sh: Do not feed shell scripts to ed.
+ * configure: Options now accept a separate argument.
+
+2013-04-23 Antonio Diaz Diaz <antonio@gnu.org>
+
+ * Version 1.8 released.
+ * io.c (get_tty_line): Removed "double EOF" behavior.
+
+2012-10-09 Antonio Diaz Diaz <ant_diaz@teleline.es>
+
+ * Version 1.7 released.
+ * main.c (main): Set invocation_name before calling show_error.
+ * Changed quote characters in messages as advised by GNU Standards.
+ * ed.texinfo: Fixed description of address offsets.
+ * ed.texinfo: Fixed a link to the Bash manual.
+ * configure: 'datadir' renamed to 'datarootdir'.
+ * Makefile.in: Added new target 'install-bin'.
+
2012-01-01 Antonio Diaz Diaz <ant_diaz@teleline.es>
* Version 1.6 released.
* io.c (put_tty_line): Null characters where incorrectly
- shown by the `l' command. (Reported by Martin Guy).
+ shown by the 'l' command. (Reported by Martin Guy).
* io.c (read_stream): Corrected the condition deciding when to
show the message "Newline appended".
- * main_loop.c (exec_command): The `modified' flag is now set
+ * main_loop.c (exec_command): The 'modified' flag is now set
when reading a non-empty file into an empty buffer.
* regex.c (translit_text): Fixed typo that prevented using NUL
characters in regular expressions.
- * main_loop.c (exec_command): Return ERR if `system' can't
+ * main_loop.c (exec_command): Return ERR if 'system' can't
create a shell process.
* main_loop.c (main_loop): Flush stdout/stderr before reading a
new command.
* buffer.c (put_sbuf_line): Added size parameter.
- * ed.1: Man page is now generated with `help2man'.
+ * ed.1: Man page is now generated with 'help2man'.
* ed.1: All command-line options are now documented in the man page.
* Restored copyright notices of Andrew L. Moore. It seems Andrew
granted some permissions but never assigned copyright to the FSF.
@@ -22,22 +59,22 @@
2010-08-30 Antonio Diaz Diaz <ant_diaz@teleline.es>
* Version 1.5 released.
- * buffer.c (append_lines): Fixed `a', `c' and `i' commands.
+ * buffer.c (append_lines): Fixed 'a', 'c' and 'i' commands.
(When used in a global command list, the commands following
them in the list were ignored).
- * main_loop.c (exec_command): Fixed `e' command. (It quitted
- when invoked a second time with a modified buffer).
- * main.c: Added new option `--restricted'.
- * `red' has been converted to a script invoking `ed --restricted'.
+ * main_loop.c (exec_command): Fixed 'e' command.
+ (It quitted when invoked a second time with a modified buffer).
+ * main.c: Added new option '--restricted'.
+ * 'red' has been converted to a script invoking 'ed --restricted'.
* Description of ed in the manual has been changed.
* testsuite: Modified some tests and removed obsolete posix tests.
- * main_loop.c: `ibufp' variable made local to main_loop.
+ * main_loop.c: 'ibufp' variable made local to main_loop.
* Defined type bool to make clear which functions and variables
are Boolean.
- * Added `const' to all pointer declarations accepting it.
+ * Added 'const' to all pointer declarations accepting it.
* regex.c (replace_matching_text): Make se_max an enum.
* signal.c: Include termios.h
- * Converted C99 style comments `//' to C89 style comments `/* */'.
+ * Converted C99 style comments '//' to C89 style comments '/* */'.
* ed.texinfo: Fixed an erratum.
* Changed copyright holder from Andrew, Antonio to the FSF.
@@ -62,9 +99,9 @@
2009-01-31 Antonio Diaz Diaz <ant_diaz@teleline.es>
* Version 1.2 released.
- * configure: Locale has been fixed to `C'.
+ * configure: Locale has been fixed to 'C'.
* Makefile.in: Man page is now installed by default.
- * `make install-info' should now work on Debian and OS X.
+ * 'make install-info' should now work on Debian and OS X.
* ed.texinfo: License updated to GFDL version 1.3 or later.
2008-10-14 Antonio Diaz Diaz <ant_diaz@teleline.es>
@@ -75,7 +112,7 @@
2008-08-21 Antonio Diaz Diaz <ant_diaz@teleline.es>
* Version 1.0 released.
- * configure: Added option `--program-prefix'.
+ * configure: Added option '--program-prefix'.
* signal.c (strip_escapes): Buffer overflow fixed.
* signal.c (resize_buffer): Pointer aliasing warning fixed.
@@ -119,16 +156,16 @@
2006-11-11 Antonio Diaz Diaz <ant_diaz@teleline.es>
* Version 0.3 released.
- * buffer.c (open_sbuf): Fixed symlink vulnerability using `tmpfile'.
+ * buffer.c (open_sbuf): Fixed symlink vulnerability using 'tmpfile'.
* signal.c: Fixed signal handling for SIGINT.
- * main_loop.c (exec_command): Fixed `c' and `i' commands with
+ * main_loop.c (exec_command): Fixed 'c' and 'i' commands with
address 0.
* The pause mode has been removed.
- * main.c: Added new options `--loose-exit-status' and `--verbose'.
- * carg_parser.c: New argument parser that replaces `getopt_long'.
- * `configure' and `Makefile.in' have been replaced.
+ * main.c: Added new options '--loose-exit-status' and '--verbose'.
+ * carg_parser.c: New argument parser that replaces 'getopt_long'.
+ * 'configure' and 'Makefile.in' have been replaced.
* Removed recursive make for testsuite.
- * Created directory `doc'.
+ * Created directory 'doc'.
* Removed all pre ISO C89 code.
* Removed all global variables.
* ed.texinfo: Added the changes from Andrew and some mine.
@@ -161,7 +198,7 @@ Tue Apr 19 10:52:51 1994 Andrew Moore <alm@woops.talke.org>
* Version 0.1. Initial release for GNU.
- * main.c (exec_command): Add comment command `#'.
+ * main.c (exec_command): Add comment command '#'.
Mon Mar 21 21:58:11 PST 1994 Andrew Moore <alm@netcom.com>
@@ -182,8 +219,7 @@ Dec 1993 François Pinard <pinard@icule>
Copyright (C) 1993 François Pinard
Copyright (C) 1994 Andrew Moore
-Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012
-Free Software Foundation, Inc.
+Copyright (C) 2006-2015 Antonio Diaz Diaz.
This file is a collection of facts, and thus it is not copyrightable,
but just in case, you have unlimited permission to copy, distribute and
diff --git a/INSTALL b/INSTALL
index 1c40c81..f7bafd8 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,7 +1,7 @@
Requirements
------------
-You'll need a C compiler and a C library compatible with GNU libc.
-I use gcc 4.3.5 and 3.3.6, but the code should compile with any
+You will need a C compiler and a C library compatible with GNU libc.
+I use gcc 4.9.1 and 3.3.6, but the code should compile with any
standards compliant compiler.
Gcc is available at http://gcc.gnu.org.
@@ -10,15 +10,15 @@ Procedure
---------
1. Unpack the archive if you have not done so already:
- lzip -cd ed[version].tar.lz | tar -xf -
+ tar -xf ed[version].tar.lz
or
- gzip -cd ed[version].tar.gz | tar -xf -
+ lzip -cd ed[version].tar.lz | tar -xf -
This creates the directory ./ed[version] containing the source from
the main archive.
2. Change to ed directory and run configure.
- (Try `configure --help' for usage instructions).
+ (Try 'configure --help' for usage instructions).
cd ed[version]
./configure
@@ -27,31 +27,38 @@ the main archive.
make
-4. Optionally, type `make check' to run the tests that come with ed.
+4. Optionally, type 'make check' to run the tests that come with ed.
-5. Type `make install' to install the program and any data files and
+5. Type 'make install' to install the program and any data files and
documentation.
+ Or type 'make install-compress', which additionally compresses the
+ info manual and the man page after installation. (Installing
+ compressed docs may become the default in the future).
+
+ You can install only the program, the info manual or the man page by
+ typing 'make install-bin', 'make install-info' or 'make install-man'
+ respectively.
+
Another way
-----------
-You can also compile ed into a separate directory. To do this, you
-must use a version of `make' that supports the `VPATH' variable, such
-as GNU `make'. `cd' to the directory where you want the object files
-and executables to go and run the `configure' script. `configure'
-automatically checks for the source code in `.', in `..' and in the
-directory that `configure' is in.
-
-`configure' recognizes the option `--srcdir=DIR' to control where to
-look for the sources. Usually `configure' can determine that directory
+You can also compile ed into a separate directory.
+To do this, you must use a version of 'make' that supports the 'VPATH'
+variable, such as GNU 'make'. 'cd' to the directory where you want the
+object files and executables to go and run the 'configure' script.
+'configure' automatically checks for the source code in '.', in '..' and
+in the directory that 'configure' is in.
+
+'configure' recognizes the option '--srcdir=DIR' to control where to
+look for the sources. Usually 'configure' can determine that directory
automatically.
-After running `configure', you can run `make' and `make install' as
+After running 'configure', you can run 'make' and 'make install' as
explained above.
-Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012
-Antonio Diaz Diaz.
+Copyright (C) 2006-2015 Antonio Diaz Diaz.
This file is free documentation: you have unlimited permission to copy,
distribute and modify it.
diff --git a/Makefile.in b/Makefile.in
index 6567008..c853e46 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,37 +1,35 @@
DISTNAME = $(pkgname)-$(pkgversion)
INSTALL = install
-INSTALL_PROGRAM = $(INSTALL) -p -m 755
-INSTALL_SCRIPT = $(INSTALL) -p -m 755
-INSTALL_DATA = $(INSTALL) -p -m 644
+INSTALL_PROGRAM = $(INSTALL) -m 755
+INSTALL_SCRIPT = $(INSTALL) -m 755
+INSTALL_DATA = $(INSTALL) -m 644
INSTALL_DIR = $(INSTALL) -d -m 755
SHELL = /bin/sh
-objs = buffer.o carg_parser.o global.o io.o \
- main.o main_loop.o regex.o signal.o
+objs = buffer.o carg_parser.o global.o io.o main.o main_loop.o regex.o signal.o
-.PHONY : all install install-info install-man install-strip \
- uninstall uninstall-info uninstall-man \
+.PHONY : all install install-bin install-info install-man \
+ install-strip install-compress install-strip-compress \
+ install-bin-strip install-info-compress install-man-compress \
+ uninstall uninstall-bin uninstall-info uninstall-man \
doc info man check dist clean distclean
all : $(progname) r$(progname)
$(progname) : $(objs)
- $(CC) $(LDFLAGS) -o $@ $(objs)
-
-$(progname)_profiled : $(objs)
- $(CC) $(LDFLAGS) -pg -o $@ $(objs)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(objs)
r$(progname) : r$(progname).in
cat $(VPATH)/r$(progname).in > $@
chmod a+x $@
main.o : main.c
- $(CC) $(CPPFLAGS) $(CFLAGS) -DPROGVERSION=\"$(pkgversion)\" -c -o $@ $<
+ $(CC) $(CFLAGS) $(CPPFLAGS) -DPROGVERSION=\"$(pkgversion)\" -c -o $@ $<
%.o : %.c
- $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
$(objs) : Makefile ed.h
carg_parser.o : carg_parser.h
@@ -42,14 +40,13 @@ doc : info man
info : $(VPATH)/doc/$(pkgname).info
-$(VPATH)/doc/$(pkgname).info : $(VPATH)/doc/$(pkgname).texinfo
- cd $(VPATH)/doc && makeinfo $(pkgname).texinfo
+$(VPATH)/doc/$(pkgname).info : $(VPATH)/doc/$(pkgname).texi
+ cd $(VPATH)/doc && makeinfo $(pkgname).texi
man : $(VPATH)/doc/$(progname).1
$(VPATH)/doc/$(progname).1 : $(progname)
- help2man -n 'line-oriented text editor' \
- -o $@ ./$(progname)
+ help2man -n 'line-oriented text editor' -o $@ ./$(progname)
Makefile : $(VPATH)/configure $(VPATH)/Makefile.in
./config.status
@@ -57,40 +54,57 @@ Makefile : $(VPATH)/configure $(VPATH)/Makefile.in
check : all
@$(VPATH)/testsuite/check.sh $(VPATH)/testsuite $(pkgversion)
-install : all install-info install-man
+install : install-bin install-info install-man
+install-strip : install-bin-strip install-info install-man
+install-compress : install-bin install-info-compress install-man-compress
+install-strip-compress : install-bin-strip install-info-compress install-man-compress
+
+install-bin : all
if [ ! -d "$(DESTDIR)$(bindir)" ] ; then $(INSTALL_DIR) "$(DESTDIR)$(bindir)" ; fi
$(INSTALL_PROGRAM) ./$(progname) "$(DESTDIR)$(bindir)/$(program_prefix)$(progname)"
$(INSTALL_SCRIPT) ./r$(progname) "$(DESTDIR)$(bindir)/$(program_prefix)r$(progname)"
+install-bin-strip : all
+ $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install-bin
+
install-info :
if [ ! -d "$(DESTDIR)$(infodir)" ] ; then $(INSTALL_DIR) "$(DESTDIR)$(infodir)" ; fi
+ -rm -f "$(DESTDIR)$(infodir)/$(pkgname).info"*
$(INSTALL_DATA) $(VPATH)/doc/$(pkgname).info "$(DESTDIR)$(infodir)/$(program_prefix)$(pkgname).info"
-install-info --info-dir="$(DESTDIR)$(infodir)" "$(DESTDIR)$(infodir)/$(program_prefix)$(pkgname).info"
+install-info-compress : install-info
+ lzip -v -9 "$(DESTDIR)$(infodir)/$(pkgname).info"
+
install-man :
if [ ! -d "$(DESTDIR)$(mandir)/man1" ] ; then $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1" ; fi
+ -rm -f "$(DESTDIR)$(mandir)/man1/$(program_prefix)$(progname).1"*
+ -rm -f "$(DESTDIR)$(mandir)/man1/$(program_prefix)r$(progname).1"*
$(INSTALL_DATA) $(VPATH)/doc/$(progname).1 "$(DESTDIR)$(mandir)/man1/$(program_prefix)$(progname).1"
- -rm -f "$(DESTDIR)$(mandir)/man1/$(program_prefix)r$(progname).1"
cd "$(DESTDIR)$(mandir)/man1" && ln -s "$(program_prefix)$(progname).1" "$(program_prefix)r$(progname).1"
-install-strip : all
- $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
+install-man-compress : install-man
+ lzip -v -9 "$(DESTDIR)$(mandir)/man1/$(program_prefix)$(progname).1"
+ -rm -f "$(DESTDIR)$(mandir)/man1/$(program_prefix)r$(progname).1"*
+ cd "$(DESTDIR)$(mandir)/man1" && ln -s "$(program_prefix)$(progname).1.lz" "$(program_prefix)r$(progname).1.lz"
+
+uninstall : uninstall-man uninstall-info uninstall-bin
-uninstall : uninstall-info uninstall-man
+uninstall-bin :
-rm -f "$(DESTDIR)$(bindir)/$(program_prefix)$(progname)"
-rm -f "$(DESTDIR)$(bindir)/$(program_prefix)r$(progname)"
uninstall-info :
-install-info --info-dir="$(DESTDIR)$(infodir)" --remove "$(DESTDIR)$(infodir)/$(program_prefix)$(pkgname).info"
- -rm -f "$(DESTDIR)$(infodir)/$(program_prefix)$(pkgname).info"
+ -rm -f "$(DESTDIR)$(infodir)/$(program_prefix)$(pkgname).info"*
uninstall-man :
- -rm -f "$(DESTDIR)$(mandir)/man1/$(program_prefix)$(progname).1"
- -rm -f "$(DESTDIR)$(mandir)/man1/$(program_prefix)r$(progname).1"
+ -rm -f "$(DESTDIR)$(mandir)/man1/$(program_prefix)$(progname).1"*
+ -rm -f "$(DESTDIR)$(mandir)/man1/$(program_prefix)r$(progname).1"*
dist : doc
ln -sf $(VPATH) $(DISTNAME)
- tar -cvf $(DISTNAME).tar \
+ tar -Hustar --owner=root --group=root -cvf $(DISTNAME).tar \
$(DISTNAME)/AUTHORS \
$(DISTNAME)/COPYING \
$(DISTNAME)/ChangeLog \
@@ -102,8 +116,8 @@ dist : doc
$(DISTNAME)/configure \
$(DISTNAME)/doc/$(progname).1 \
$(DISTNAME)/doc/$(pkgname).info \
- $(DISTNAME)/doc/$(pkgname).texinfo \
- $(DISTNAME)/doc/fdl.texinfo \
+ $(DISTNAME)/doc/$(pkgname).texi \
+ $(DISTNAME)/doc/fdl.texi \
$(DISTNAME)/r$(progname).in \
$(DISTNAME)/testsuite/check.sh \
$(DISTNAME)/testsuite/*.t \
@@ -117,7 +131,7 @@ dist : doc
lzip -v -9 $(DISTNAME).tar
clean :
- -rm -f $(progname) r$(progname) $(progname)_profiled $(objs)
+ -rm -f $(progname) r$(progname) $(objs)
distclean : clean
-rm -f Makefile config.status *.tar *.tar.lz
diff --git a/NEWS b/NEWS
index 5f4c6ad..5cb43ae 100644
--- a/NEWS
+++ b/NEWS
@@ -1,20 +1,11 @@
-Changes in version 1.6:
+Changes in version 1.11:
-Displaying of null characters by the "l" command has been fixed.
+The "z" command has been fixed. ("zN" printed N + 1 lines). This bug was
+present since at least ed-0.2.
-The condition deciding when to show the message "Newline appended" has
-been corrected.
+The window size used by the "z" command has been documented in the
+manual.
-The "modified" flag is now set when reading a non-empty file into an
-empty buffer.
-
-An error that prevented using NUL characters in regular expressions has
-been fixed.
-
-Ed now signals an error if it can't create a shell process when
-executing a shell command.
-
-Ed now flushes stdout/stderr before reading a new command.
-
-Man page is now generated with "help2man". All command-line options are
-now documented in the man page.
+The targets "install-compress", "install-strip-compress",
+"install-info-compress" and "install-man-compress" have been added to
+the Makefile.
diff --git a/README b/README
index db577d3..bc86c71 100644
--- a/README
+++ b/README
@@ -1,3 +1,5 @@
+Description
+
GNU ed is a line-oriented text editor. It is used to create, display,
modify and otherwise manipulate text files, both interactively and via
shell scripts. A restricted version of ed, red, can only edit files in
@@ -12,12 +14,12 @@ See the file INSTALL for compilation and installation instructions.
Try "ed --help" for usage instructions.
-Report bugs to <bug-ed@gnu.org>.
+Report bugs to bug-ed@gnu.org
Ed home page: http://www.gnu.org/software/ed/ed.html
For a description of the ed algorithm, see Kernighan and Plauger's book
-"Software Tools in Pascal," Addison-Wesley, 1981.
+"Software Tools in Pascal", Addison-Wesley, 1981.
GNU ed(1) is not strictly POSIX compliant, as described in the
@@ -44,25 +46,25 @@ EXTENSIONS
r /dev/null
wq
- Similarly, to remove a newline from the end of binary `file':
+ Similarly, to remove a newline from the end of binary 'file':
$ ed file
r /dev/null
wq
* BSD commands have been implemented wherever they do not conflict with
the POSIX standard. The BSD-ism's included are:
- * `s' (i.e., s[n][rgp]*) to repeat a previous substitution,
- * `W' for appending text to an existing file,
- * `wq' for exiting after a write, and
- * `z' for scrolling through the buffer.
-
- * The POSIX interactive global commands `G' and `V' are extended to
- support multiple commands, including `a', `i' and `c'. The command
- format is the same as for the global commands `g' and `v', i.e., one
+ * 's' (i.e., s[n][rgp]*) to repeat a previous substitution,
+ * 'W' for appending text to an existing file,
+ * 'wq' for exiting after a write, and
+ * 'z' for scrolling through the buffer.
+
+ * The POSIX interactive global commands 'G' and 'V' are extended to
+ support multiple commands, including 'a', 'i' and 'c'. The command
+ format is the same as for the global commands 'g' and 'v', i.e., one
command per line with each line, except for the last, ending in a
backslash (\).
- * The file commands `E', `e', `r', `W' and `w' process a <file>
+ * The file commands 'E', 'e', 'r', 'W' and 'w' process a <file>
argument for backslash escapes; i.e., any character preceded by a
backslash is interpreted literally. If the first unescaped character
of a <file> argument is a bang (!), then the rest of the line is
@@ -79,23 +81,23 @@ DEVIATIONS
addresses cannot be used where only a single address is expected has
been relaxed.
- * To support the BSD `s' command (see EXTENSIONS above),
+ * To support the BSD 's' command (see EXTENSIONS above),
substitution patterns cannot be delimited by numbers or the characters
- `r', `g' and `p'. In contrast, POSIX specifies any character expect
+ 'r', 'g' and 'p'. In contrast, POSIX specifies any character expect
space or newline can used as a delimiter.
- * Since the behavior of `u' (undo) within a `g' (global) command list is
+ * Since the behavior of 'u' (undo) within a 'g' (global) command list is
not specified by POSIX, GNU ed follows the behavior of the SunOS ed:
undo forces a global command list to be executed only once, rather than
for each line matching a global pattern. In addtion, each instance of
- `u' within a global command undoes all previous commands (including
+ 'u' within a global command undoes all previous commands (including
undo's) in the command list. This seems the best way, since the
alternatives are either too complicated to implement or too confusing
to use.
- * The `m' (move) command within a `g' command list also follows the SunOS
+ * The 'm' (move) command within a 'g' command list also follows the SunOS
ed implementation: any moved lines are removed from the global command's
- `active' list.
+ 'active' list.
* If GNU ed is invoked with a name argument prefixed by a bang (!), then
the remainder of the argument is interpreted as a shell command. To invoke
@@ -109,9 +111,9 @@ DEVIATIONS
TESTSUITE
---------
-The files in the `testsuite' directory with suffixes `.t', `.d', `.r',
-`.pr' and `.err' are used for testing ed. To run the tests, configure
-the package and type `make check' from the build directory. The tests do
+The files in the 'testsuite' directory with suffixes '.t', '.d', '.r',
+'.pr' and '.err' are used for testing ed. To run the tests, configure
+the package and type 'make check' from the build directory. The tests do
not exhaustively verify POSIX compliance nor do they verify correct
8-bit or long line support.
@@ -124,9 +126,9 @@ The test file suffixes have the following meanings:
.pr Result from a piped ed script.
.err Error - invalid ed commands that should generate an error
-The output of the tests is written to the files errs.ck, pipes.ck and
-scripts.ck. At the end of the tests, these files are grep'ed for error
-messages, which look like:
+The output of the tests is written to files with .o and .ro suffixes and
+compared with their corresponding .r and .pr result files.
+If any test fails, the error messages look like:
*** The script u.ed exited abnormally ***
or:
@@ -134,8 +136,7 @@ or:
Copyright (C) 1993, 1994 Andrew Moore
-Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012
-Free Software Foundation, Inc.
+Copyright (C) 2006-2015 Antonio Diaz Diaz.
This file is free documentation: you have unlimited permission to copy,
distribute and modify it.
diff --git a/TODO b/TODO
index 7a4b74f..3f777e4 100644
--- a/TODO
+++ b/TODO
@@ -4,12 +4,8 @@ Some missing tests:
2) a
hello^V^Jworld
. - okay: embedded newlines in insert mode
-3) ed "" - error: invalid filename
-4) red .. - error: restricted
-5) red / - error: restricted
-5) red !xx - error: restricted
-6) ed -x - verify: 8-bit clean
-7) ed - verify: long-line support
-8) ed - verify: interactive/help mode
-9) G/pat/ - verify: global interactive command
-10) V/pat/ - verify: global interactive command
+3) ed -x - verify: 8-bit clean
+4) ed - verify: long-line support
+5) ed - verify: interactive/help mode
+6) G/pat/ - verify: global interactive command
+7) V/pat/ - verify: global interactive command
diff --git a/buffer.c b/buffer.c
index 8b4784f..8a2e268 100644
--- a/buffer.c
+++ b/buffer.c
@@ -1,12 +1,11 @@
/* buffer.c: scratch-file buffer routines for the ed line editor. */
/* GNU ed - The GNU line editor.
Copyright (C) 1993, 1994 Andrew Moore, Talke Studio
- Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012
- Free Software Foundation, Inc.
+ Copyright (C) 2006-2015 Antonio Diaz Diaz.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
+ the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -107,7 +106,7 @@ static line_t * dup_line_node( line_t * const lp )
/* Insert text from stdin (or from command buffer if global) to after
line n; stop when either a single period is read or EOF.
- Return false if insertion fails. */
+ Returns false if insertion fails. */
bool append_lines( const char ** const ibufpp, const int addr,
const bool isglobal )
{
@@ -492,7 +491,7 @@ line_t * search_line_node( const int addr )
}
}
else if( o_addr <= 2 * addr )
- while( o_addr > addr ) { --o_addr; lp = lp->q_back; }
+ while( o_addr > addr ) { --o_addr; lp = lp->q_back; }
else
{ lp = &buffer_head; o_addr = 0;
while( o_addr < addr ) { ++o_addr; lp = lp->q_forw; } }
diff --git a/carg_parser.c b/carg_parser.c
index fa3be26..a453e36 100644
--- a/carg_parser.c
+++ b/carg_parser.c
@@ -1,10 +1,9 @@
/* Arg_parser - POSIX/GNU command line argument parser. (C version)
- Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012
- Antonio Diaz Diaz.
+ Copyright (C) 2006-2015 Antonio Diaz Diaz.
This library is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
+ the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This library is distributed in the hope that it will be useful,
@@ -32,7 +31,7 @@
#include "carg_parser.h"
-/* assure at least a minimum size for buffer `buf' */
+/* assure at least a minimum size for buffer 'buf' */
static void * ap_resize_buffer( void * buf, const int min_size )
{
if( buf ) buf = realloc( buf, min_size );
@@ -45,7 +44,7 @@ static char push_back_record( struct Arg_parser * const ap,
const int code, const char * const argument )
{
const int len = strlen( argument );
- struct ap_Record *p;
+ struct ap_Record * p;
void * tmp = ap_resize_buffer( ap->data,
( ap->data_size + 1 ) * sizeof (struct ap_Record) );
if( !tmp ) return 0;
@@ -88,16 +87,15 @@ static char parse_long_option( struct Arg_parser * const ap,
const struct ap_Option options[],
int * const argindp )
{
- unsigned int len;
- int index = -1;
- int i;
+ unsigned len;
+ int index = -1, i;
char exact = 0, ambig = 0;
for( len = 0; opt[len+2] && opt[len+2] != '='; ++len ) ;
/* Test all long options for either exact match or abbreviated matches. */
for( i = 0; options[i].code != 0; ++i )
- if( options[i].name && !strncmp( options[i].name, &opt[2], len ) )
+ if( options[i].name && strncmp( options[i].name, &opt[2], len ) == 0 )
{
if( strlen( options[i].name ) == len ) /* Exact match found */
{ index = i; exact = 1; break; }
@@ -109,31 +107,31 @@ static char parse_long_option( struct Arg_parser * const ap,
if( ambig && !exact )
{
- add_error( ap, "option `" ); add_error( ap, opt );
+ add_error( ap, "option '" ); add_error( ap, opt );
add_error( ap, "' is ambiguous" );
return 1;
}
if( index < 0 ) /* nothing found */
{
- add_error( ap, "unrecognized option `" ); add_error( ap, opt );
+ add_error( ap, "unrecognized option '" ); add_error( ap, opt );
add_error( ap, "'" );
return 1;
}
++*argindp;
- if( opt[len+2] ) /* `--<long_option>=<argument>' syntax */
+ if( opt[len+2] ) /* '--<long_option>=<argument>' syntax */
{
if( options[index].has_arg == ap_no )
{
- add_error( ap, "option `--" ); add_error( ap, options[index].name );
+ add_error( ap, "option '--" ); add_error( ap, options[index].name );
add_error( ap, "' doesn't allow an argument" );
return 1;
}
if( options[index].has_arg == ap_yes && !opt[len+3] )
{
- add_error( ap, "option `--" ); add_error( ap, options[index].name );
+ add_error( ap, "option '--" ); add_error( ap, options[index].name );
add_error( ap, "' requires an argument" );
return 1;
}
@@ -144,7 +142,7 @@ static char parse_long_option( struct Arg_parser * const ap,
{
if( !arg || !arg[0] )
{
- add_error( ap, "option `--" ); add_error( ap, options[index].name );
+ add_error( ap, "option '--" ); add_error( ap, options[index].name );
add_error( ap, "' requires an argument" );
return 1;
}
@@ -165,8 +163,7 @@ static char parse_short_option( struct Arg_parser * const ap,
while( cind > 0 )
{
- int index = -1;
- int i;
+ int index = -1, i;
const unsigned char code = opt[cind];
char code_str[2];
code_str[0] = code; code_str[1] = 0;
@@ -178,7 +175,8 @@ static char parse_short_option( struct Arg_parser * const ap,
if( index < 0 )
{
- add_error( ap, "invalid option -- " ); add_error( ap, code_str );
+ add_error( ap, "invalid option -- '" ); add_error( ap, code_str );
+ add_error( ap, "'" );
return 1;
}
@@ -193,8 +191,8 @@ static char parse_short_option( struct Arg_parser * const ap,
{
if( !arg || !arg[0] )
{
- add_error( ap, "option requires an argument -- " );
- add_error( ap, code_str );
+ add_error( ap, "option requires an argument -- '" );
+ add_error( ap, code_str ); add_error( ap, "'" );
return 1;
}
++*argindp; cind = 0;
@@ -224,12 +222,12 @@ char ap_init( struct Arg_parser * const ap,
while( argind < argc )
{
const unsigned char ch1 = argv[argind][0];
- const unsigned char ch2 = ( ch1 ? argv[argind][1] : 0 );
+ const unsigned char ch2 = ch1 ? argv[argind][1] : 0;
if( ch1 == '-' && ch2 ) /* we found an option */
{
const char * const opt = argv[argind];
- const char * const arg = (argind + 1 < argc) ? argv[argind+1] : 0;
+ const char * const arg = ( argind + 1 < argc ) ? argv[argind+1] : 0;
if( ch2 == '-' )
{
if( !argv[argind][2] ) { ++argind; break; } /* we found "--" */
diff --git a/carg_parser.h b/carg_parser.h
index fdff4d5..34b1263 100644
--- a/carg_parser.h
+++ b/carg_parser.h
@@ -1,10 +1,9 @@
/* Arg_parser - POSIX/GNU command line argument parser. (C version)
- Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012
- Antonio Diaz Diaz.
+ Copyright (C) 2006-2015 Antonio Diaz Diaz.
This library is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
+ the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This library is distributed in the hope that it will be useful,
@@ -26,13 +25,13 @@
Public License.
*/
-/* Arg_parser reads the arguments in `argv' and creates a number of
+/* Arg_parser reads the arguments in 'argv' and creates a number of
option codes, option arguments and non-option arguments.
- In case of error, `ap_error' returns a non-null pointer to an error
+ In case of error, 'ap_error' returns a non-null pointer to an error
message.
- `options' is an array of `struct ap_Option' terminated by an element
+ 'options' is an array of 'struct ap_Option' terminated by an element
containing a code which is zero. A null name means a short-only
option. A code value outside the unsigned char range means a
long-only option.
@@ -41,13 +40,13 @@
were specified before all the non-option arguments for the purposes
of parsing, even if the user of your program intermixed option and
non-option arguments. If you want the arguments in the exact order
- the user typed them, call `ap_init' with `in_order' = true.
+ the user typed them, call 'ap_init' with 'in_order' = true.
- The argument `--' terminates all options; any following arguments are
+ The argument '--' terminates all options; any following arguments are
treated as non-option arguments, even if they begin with a hyphen.
- The syntax for optional option arguments is `-<short_option><argument>'
- (without whitespace), or `--<long_option>=<argument>'.
+ The syntax for optional option arguments is '-<short_option><argument>'
+ (without whitespace), or '--<long_option>=<argument>'.
*/
#ifdef __cplusplus
diff --git a/configure b/configure
index d01a036..9f5742c 100755
--- a/configure
+++ b/configure
@@ -1,17 +1,14 @@
#! /bin/sh
# configure script for GNU ed - The GNU line editor
-# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012
-# Antonio Diaz Diaz.
+# Copyright (C) 2006-2015 Antonio Diaz Diaz.
#
# This configure script is free software: you have unlimited permission
# to copy, distribute and modify it.
-args=
-no_create=
pkgname=ed
-pkgversion=1.6
+pkgversion=1.11
progname=ed
-srctrigger=ed.h
+srctrigger=doc/${pkgname}.texi
# clear some things potentially inherited from environment.
LC_ALL=C
@@ -20,21 +17,29 @@ srcdir=
prefix=/usr/local
exec_prefix='$(prefix)'
bindir='$(exec_prefix)/bin'
-datadir='$(prefix)/share'
-infodir='$(datadir)/info'
-mandir='$(datadir)/man'
-sysconfdir='$(prefix)/etc'
+datarootdir='$(prefix)/share'
+infodir='$(datarootdir)/info'
+mandir='$(datarootdir)/man'
program_prefix=
-CC=
+CC=gcc
CPPFLAGS=
CFLAGS='-Wall -W -O2'
LDFLAGS=
+# checking whether we are using GNU C.
+${CC} --version > /dev/null 2>&1
+if [ $? != 0 ] ; then
+ CC=cc
+ CFLAGS='-W -O2'
+fi
+
# Loop over all args
-while [ -n "$1" ] ; do
+args=
+no_create=
+while [ $# != 0 ] ; do
# Get the first arg, and shuffle
- option=$1
+ option=$1 ; arg2=no
shift
# Add the argument quoted to args
@@ -42,12 +47,12 @@ while [ -n "$1" ] ; do
# Split out the argument for options that take them
case ${option} in
- *=*) optarg=`echo ${option} | sed -e 's,^[^=]*=,,'` ;;
+ *=*) optarg=`echo ${option} | sed -e 's,^[^=]*=,,;s,/$,,'` ;;
esac
# Process the options
case ${option} in
- --help | --he* | -h)
+ --help | -h)
echo "Usage: configure [options]"
echo
echo "Options: [defaults in brackets]"
@@ -57,85 +62,80 @@ while [ -n "$1" ] ; do
echo " --prefix=DIR install into DIR [${prefix}]"
echo " --exec-prefix=DIR base directory for arch-dependent files [${exec_prefix}]"
echo " --bindir=DIR user executables directory [${bindir}]"
- echo " --datadir=DIR base directory for doc and data [${datadir}]"
+ echo " --datarootdir=DIR base directory for doc and data [${datarootdir}]"
echo " --infodir=DIR info files directory [${infodir}]"
echo " --mandir=DIR man pages directory [${mandir}]"
- echo " --sysconfdir=DIR read-only single-machine data directory [${sysconfdir}]"
echo " --program-prefix=NAME install program and documentation prefixed with NAME"
- echo " CC=COMPILER C compiler to use [gcc]"
+ echo " CC=COMPILER C compiler to use [${CC}]"
echo " CPPFLAGS=OPTIONS command line options for the preprocessor [${CPPFLAGS}]"
echo " CFLAGS=OPTIONS command line options for the C compiler [${CFLAGS}]"
echo " LDFLAGS=OPTIONS command line options for the linker [${LDFLAGS}]"
echo
exit 0 ;;
- --version | --ve* | -V)
+ --version | -V)
echo "Configure script for GNU ${pkgname} version ${pkgversion}"
exit 0 ;;
- --srcdir* | --sr*)
- srcdir=`echo ${optarg} | sed -e 's,/$,,'` ;;
- --prefix* | --pre*)
- prefix=`echo ${optarg} | sed -e 's,/$,,'` ;;
- --exec-prefix* | --ex*)
- exec_prefix=`echo ${optarg} | sed -e 's,/$,,'` ;;
- --bindir* | --bi*)
- bindir=`echo ${optarg} | sed -e 's,/$,,'` ;;
- --datadir* | --da*)
- datadir=`echo ${optarg} | sed -e 's,/$,,'` ;;
- --infodir* | --inf*)
- infodir=`echo ${optarg} | sed -e 's,/$,,'` ;;
- --mandir* | --ma*)
- mandir=`echo ${optarg} | sed -e 's,/$,,'` ;;
- --sysconfdir* | --sy*)
- sysconfdir=`echo ${optarg} | sed -e 's,/$,,'` ;;
- --program-prefix* | --pro*)
- program_prefix=`echo ${optarg} | sed -e 's,/$,,'` ;;
- --no-create | --no-c*)
- no_create=yes ;;
-
- CC=*) CC=${optarg} ;;
+ --srcdir) srcdir=$1 ; arg2=yes ;;
+ --prefix) prefix=$1 ; arg2=yes ;;
+ --exec-prefix) exec_prefix=$1 ; arg2=yes ;;
+ --bindir) bindir=$1 ; arg2=yes ;;
+ --datarootdir) datarootdir=$1 ; arg2=yes ;;
+ --infodir) infodir=$1 ; arg2=yes ;;
+ --mandir) mandir=$1 ; arg2=yes ;;
+ --program-prefix) program_prefix=$1 ; arg2=yes ;;
+
+ --srcdir=*) srcdir=${optarg} ;;
+ --prefix=*) prefix=${optarg} ;;
+ --exec-prefix=*) exec_prefix=${optarg} ;;
+ --bindir=*) bindir=${optarg} ;;
+ --datarootdir=*) datarootdir=${optarg} ;;
+ --infodir=*) infodir=${optarg} ;;
+ --mandir=*) mandir=${optarg} ;;
+ --program-prefix=*) program_prefix=${optarg} ;;
+ --no-create) no_create=yes ;;
+
+ CC=*) CC=${optarg} ;;
CPPFLAGS=*) CPPFLAGS=${optarg} ;;
- CFLAGS=*) CFLAGS=${optarg} ;;
- LDFLAGS=*) LDFLAGS=${optarg} ;;
+ CFLAGS=*) CFLAGS=${optarg} ;;
+ LDFLAGS=*) LDFLAGS=${optarg} ;;
- --* | *=* | *-*-*) ;;
+ --*)
+ echo "configure: WARNING: unrecognized option: '${option}'" 1>&2 ;;
+ *=* | *-*-*) ;;
*)
- echo "configure: Unrecognized option: \"${option}\"; use --help for usage." 1>&2
+ echo "configure: unrecognized option: '${option}'" 1>&2
+ echo "Try 'configure --help' for more information." 1>&2
exit 1 ;;
esac
+
+ # Check if the option took a separate argument
+ if [ "${arg2}" = yes ] ; then
+ if [ $# != 0 ] ; then args="${args} \"$1\"" ; shift
+ else echo "configure: Missing argument to '${option}'" 1>&2
+ exit 1
+ fi
+ fi
done
# Find the source files, if location was not specified.
srcdirtext=
if [ -z "${srcdir}" ] ; then
srcdirtext="or . or .." ; srcdir=.
- if [ ! -r ${srcdir}/${srctrigger} ] ; then srcdir=.. ; fi
- if [ ! -r ${srcdir}/${srctrigger} ] ; then
+ if [ ! -r "${srcdir}/${srctrigger}" ] ; then srcdir=.. ; fi
+ if [ ! -r "${srcdir}/${srctrigger}" ] ; then
## the sed command below emulates the dirname command
srcdir=`echo $0 | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
fi
fi
-if [ ! -r ${srcdir}/${srctrigger} ] ; then
- exec 1>&2
- echo
- echo "configure: Can't find sources in ${srcdir} ${srcdirtext}"
- echo "configure: (At least ${srctrigger} is missing)."
+if [ ! -r "${srcdir}/${srctrigger}" ] ; then
+ echo "configure: Can't find sources in ${srcdir} ${srcdirtext}" 1>&2
+ echo "configure: (At least ${srctrigger} is missing)." 1>&2
exit 1
fi
# Set srcdir to . if that's what it is.
-if [ "`pwd`" = "`cd ${srcdir} ; pwd`" ] ; then srcdir=. ; fi
-
-# checking whether we are using GNU C.
-if [ -z "${CC}" ] ; then # Let the user override the test.
- if [ -x /bin/gcc ] ||
- [ -x /usr/bin/gcc ] ||
- [ -x /usr/local/bin/gcc ] ; then
- CC="gcc"
- else
- CC="cc"
- fi
-fi
+if [ "`pwd`" = "`cd "${srcdir}" ; pwd`" ] ; then srcdir=. ; fi
echo
if [ -z "${no_create}" ] ; then
@@ -159,10 +159,9 @@ echo "VPATH = ${srcdir}"
echo "prefix = ${prefix}"
echo "exec_prefix = ${exec_prefix}"
echo "bindir = ${bindir}"
-echo "datadir = ${datadir}"
+echo "datarootdir = ${datarootdir}"
echo "infodir = ${infodir}"
echo "mandir = ${mandir}"
-echo "sysconfdir = ${sysconfdir}"
echo "program_prefix = ${program_prefix}"
echo "CC = ${CC}"
echo "CPPFLAGS = ${CPPFLAGS}"
@@ -171,8 +170,7 @@ echo "LDFLAGS = ${LDFLAGS}"
rm -f Makefile
cat > Makefile << EOF
# Makefile for GNU ed - The GNU line editor
-# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012
-# Antonio Diaz Diaz.
+# Copyright (C) 2006-2015 Antonio Diaz Diaz.
# This file was generated automatically by configure. Do not edit.
#
# This Makefile is free software: you have unlimited permission
@@ -185,16 +183,15 @@ VPATH = ${srcdir}
prefix = ${prefix}
exec_prefix = ${exec_prefix}
bindir = ${bindir}
-datadir = ${datadir}
+datarootdir = ${datarootdir}
infodir = ${infodir}
mandir = ${mandir}
-sysconfdir = ${sysconfdir}
program_prefix = ${program_prefix}
CC = ${CC}
CPPFLAGS = ${CPPFLAGS}
CFLAGS = ${CFLAGS}
LDFLAGS = ${LDFLAGS}
EOF
-cat ${srcdir}/Makefile.in >> Makefile
+cat "${srcdir}/Makefile.in" >> Makefile
echo "OK. Now you can run make."
diff --git a/doc/ed.1 b/doc/ed.1
index 2a0708a..1126b9d 100644
--- a/doc/ed.1
+++ b/doc/ed.1
@@ -1,10 +1,10 @@
-.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
-.TH ED "1" "January 2012" "Ed 1.6" "User Commands"
+.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.46.1.
+.TH ED "1" "March 2015" "ed 1.11" "User Commands"
.SH NAME
-Ed \- line-oriented text editor
+ed \- line-oriented text editor
.SH SYNOPSIS
.B ed
-[\fIoptions\fR] [\fIfile\fR]
+[\fI\,options\/\fR] [\fI\,file\/\fR]
.SH DESCRIPTION
GNU Ed \- The GNU line editor.
.SH OPTIONS
@@ -21,7 +21,7 @@ run in compatibility mode
\fB\-l\fR, \fB\-\-loose\-exit\-status\fR
exit with 0 status even if a command fails
.TP
-\fB\-p\fR, \fB\-\-prompt\fR=\fISTRING\fR
+\fB\-p\fR, \fB\-\-prompt\fR=\fI\,STRING\/\fR
use STRING as an interactive prompt
.TP
\fB\-r\fR, \fB\-\-restricted\fR
@@ -33,10 +33,15 @@ suppress diagnostics
\fB\-v\fR, \fB\-\-verbose\fR
be verbose
.PP
-Start edit by reading in `file' if given.
-If `file' begins with a `!', read output of shell command.
+Start edit by reading in 'file' if given.
+If 'file' begins with a '!', read output of shell command.
+.PP
+Exit status: 0 for a normal exit, 1 for environmental problems (file
+not found, invalid flags, I/O errors, etc), 2 to indicate a corrupt or
+invalid input file, 3 for an internal consistency error (eg, bug) which
+caused ed to panic.
.SH "REPORTING BUGS"
-Report bugs to <bug\-ed@gnu.org>.
+Report bugs to bug\-ed@gnu.org
.br
Ed home page: http://www.gnu.org/software/ed/ed.html
.br
@@ -44,20 +49,20 @@ General help using GNU software: http://www.gnu.org/gethelp
.SH COPYRIGHT
Copyright \(co 1994 Andrew L. Moore.
.br
-Copyright \(co 2012 Free Software Foundation, Inc.
+Copyright \(co 2015 Antonio Diaz Diaz.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
.br
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
.SH "SEE ALSO"
The full documentation for
-.B Ed
+.B ed
is maintained as a Texinfo manual. If the
.B info
and
-.B Ed
+.B ed
programs are properly installed at your site, the command
.IP
-.B info Ed
+.B info ed
.PP
should give you access to the complete manual.
diff --git a/doc/ed.info b/doc/ed.info
index 655ea94..98650bc 100644
--- a/doc/ed.info
+++ b/doc/ed.info
@@ -1,12 +1,11 @@
-This is ed.info, produced by makeinfo version 4.13 from ed.texinfo.
+This is ed.info, produced by makeinfo version 4.13+ from ed.texi.
INFO-DIR-SECTION Basics
START-INFO-DIR-ENTRY
* Ed: (ed). The GNU line editor
END-INFO-DIR-ENTRY
- Copyright (C) 1993, 1994, 2006, 2007, 2008, 2009, 2010, 2011, 2012
-Free Software Foundation, Inc.
+ Copyright (C) 1993, 1994, 2006-2015 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -19,7 +18,7 @@ File: ed.info, Node: Top, Next: Overview, Up: (dir)
The GNU ed line editor
**********************
-This manual is for GNU ed (version 1.6, 1 January 2012).
+This manual is for GNU ed (version 1.11, 30 March 2015).
GNU ed is a line-oriented text editor. It is used to create, display,
@@ -32,20 +31,19 @@ superseded by full-screen editors such as GNU Emacs or GNU Moe.
* Menu:
-* Overview:: Overview of the `ed' command
-* Introduction to Line Editing:: Getting started with GNU `ed'
-* Invoking Ed:: Command line interface
-* Line Addressing:: Specifying lines/ranges in the buffer
-* Regular Expressions:: Patterns for selecting text
-* Commands:: Commands recognized by GNU `ed'
-* Limitations:: Intrinsic limits of GNU `ed'
-* Diagnostics:: GNU `ed' error handling
-* Problems:: Reporting bugs
-* GNU Free Documentation License:: How you can copy and share this manual
+* Overview:: Overview of the 'ed' command
+* Introduction to line editing:: Getting started with GNU 'ed'
+* Invoking ed:: Command line interface
+* Line addressing:: Specifying lines/ranges in the buffer
+* Regular expressions:: Patterns for selecting text
+* Commands:: Commands recognized by GNU 'ed'
+* Limitations:: Intrinsic limits of GNU 'ed'
+* Diagnostics:: GNU 'ed' error handling
+* Problems:: Reporting bugs
+* GNU Free Documentation License:: How you can copy and share this manual
- Copyright (C) 1993, 1994, 2006, 2007, 2008, 2009, 2010, 2011, 2012
-Free Software Foundation, Inc.
+ Copyright (C) 1993, 1994, 2006-2015 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -53,23 +51,23 @@ any later version published by the Free Software Foundation; with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.

-File: ed.info, Node: Overview, Next: Introduction to Line Editing, Prev: Top, Up: Top
+File: ed.info, Node: Overview, Next: Introduction to line editing, Prev: Top, Up: Top
1 Overview
**********
-`ed' is a line-oriented text editor. It is used to create, display,
-modify and otherwise manipulate text files. `red' is a restricted `ed':
+'ed' is a line-oriented text editor. It is used to create, display,
+modify and otherwise manipulate text files. 'red' is a restricted 'ed':
it can only edit files in the current directory and cannot execute
shell commands.
If invoked with a FILE argument, then a copy of FILE is read into
the editor's buffer. Changes are made to this copy and not directly to
-FILE itself. Upon quitting `ed', any changes not explicitly saved with
-a `w' command are lost.
+FILE itself. Upon quitting 'ed', any changes not explicitly saved with
+a 'w' command are lost.
Editing is done in two distinct modes: "command" and "input". When
-first invoked, `ed' is in command mode. In this mode commands are read
+first invoked, 'ed' is in command mode. In this mode commands are read
from the standard input and executed to manipulate the contents of the
editor buffer. A typical command might look like:
@@ -77,20 +75,20 @@ editor buffer. A typical command might look like:
which replaces all occurences of the string OLD with NEW.
- When an input command, such as `a' (append), `i' (insert) or `c'
-(change), is given, `ed' enters input mode. This is the primary means
+ When an input command, such as 'a' (append), 'i' (insert) or 'c'
+(change), is given, 'ed' enters input mode. This is the primary means
of adding text to a file. In this mode, no commands are available;
instead, the standard input is written directly to the editor buffer. A
"line" consists of the text up to and including a <newline> character.
-Input mode is terminated by entering a single period (`.') on a line.
+Input mode is terminated by entering a single period ('.') on a line.
- All `ed' commands operate on whole lines or ranges of lines; e.g.,
-the `d' command deletes lines; the `m' command moves lines, and so on.
+ All 'ed' commands operate on whole lines or ranges of lines; e.g.,
+the 'd' command deletes lines; the 'm' command moves lines, and so on.
It is possible to modify only a portion of a line by means of
-replacement, as in the example above. However even here, the `s'
+replacement, as in the example above. However even here, the 's'
command is applied to whole lines at a time.
- In general, `ed' commands consist of zero or more line addresses,
+ In general, 'ed' commands consist of zero or more line addresses,
followed by a single character command and possibly additional
parameters; i.e., commands have the structure:
@@ -101,51 +99,52 @@ the command. If fewer addresses are given than the command accepts,
then default addresses are supplied.

-File: ed.info, Node: Introduction to Line Editing, Next: Invoking Ed, Prev: Overview, Up: Top
+File: ed.info, Node: Introduction to line editing, Next: Invoking ed, Prev: Overview, Up: Top
-2 Introduction to Line Editing
+2 Introduction to line editing
******************************
-`ed' was created, along with the Unix operating system, by Ken Thompson
+'ed' was created, along with the Unix operating system, by Ken Thompson
and Dennis Ritchie. It is the refinement of its more complex,
-programmable predecessor, `QED', to which Thompson and Ritchie had
+programmable predecessor, 'QED', to which Thompson and Ritchie had
already added pattern matching capabilities (*note Regular
-Expressions::).
+expressions::).
For the purposes of this tutorial, a working knowledge of the Unix
-shell `sh' (*note Bash: (bash)Bash.) and the Unix file system is
-recommended, since `ed' is designed to interact closely with them.
+shell 'sh' and the Unix file system is recommended, since 'ed' is
+designed to interact closely with them. (*Note GNU bash manual:
+(bash)Top, for details about bash).
The principal difference between line editors and display editors is
that display editors provide instant feedback to user commands, whereas
line editors require sometimes lengthy input before any effects are
seen. The advantage of instant feedback, of course, is that if a mistake
is made, it can be corrected immediately, before more damage is done.
-Editing in `ed' requires more strategy and forethought; but if you are
+Editing in 'ed' requires more strategy and forethought; but if you are
up to the task, it can be quite efficient.
- Much of the `ed' command syntax is shared with other Unix utilities.
+ Much of the 'ed' command syntax is shared with other Unix utilities.
As with the shell, <RETURN> (the carriage-return key) enters a line
of input. So when we speak of "entering" a command or some text in
-`ed', <RETURN> is implied at the end of each line. Prior to typing
+'ed', <RETURN> is implied at the end of each line. Prior to typing
<RETURN>, corrections to the line may be made by typing either
<BACKSPACE> (sometimes labeled <DELETE> or <DEL>) to erase characters
backwards, or <CONTROL>-u (i.e., hold the CONTROL key and type u) to
erase the whole line.
- When `ed' first opens, it expects to be told what to do but doesn't
-prompt us like the shell. So let's begin by telling `ed' to do so with
+ When 'ed' first opens, it expects to be told what to do but doesn't
+prompt us like the shell. So let's begin by telling 'ed' to do so with
the <P> ("prompt") command:
$ ed
P
*
- By default, `ed' uses asterisk (`*') as command prompt to avoid
-confusion with the shell command prompt (`$').
+ By default, 'ed' uses asterisk ('*') as command prompt to avoid
+confusion with the shell command prompt ('$').
- We can run Unix shell (`sh') commands from inside `ed' by prefixing
+ We can run Unix shell ('sh') commands from inside 'ed' by prefixing
them with <!> (exclamation mark, aka "bang"). For example:
*!date
@@ -160,15 +159,15 @@ them with <!> (exclamation mark, aka "bang"). For example:
So far, this is no different from running commands in the Unix shell.
But let's say we want to edit the output of a command, or save it to a
file. First we must capture the command output to a temporary location
-called a "buffer" where `ed' can access it. This is done with `ed''s
+called a "buffer" where 'ed' can access it. This is done with 'ed''s
<r> command (mnemonic: "read"):
- *r !cal
- 143
+ *r !cal -m
+ 137
*
- Here `ed' is telling us that it has just read 143 characters into
-the editor buffer - i.e., the output of the `cal' command, which prints
+ Here 'ed' is telling us that it has just read 137 characters into
+the editor buffer - i.e., the output of the 'cal' command, which prints
a simple ASCII calendar. To display the buffer contents we issue the
<p> ("print") command (not to be confused with the prompt command,
which is uppercase!). To indicate the range of lines in the buffer that
@@ -176,58 +175,58 @@ should be printed, we prefix the command with <,> (comma) which is
shorthand for "the whole buffer":
*,p
- September 2006
+ June 2006
Mo Tu We Th Fr Sa Su
- 1 2 3
- 4 5 6 7 8 9 10
- 11 12 13 14 15 16 17
- 18 19 20 21 22 23 24
- 25 26 27 28 29 30
+ 1 2 3 4
+ 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18
+ 19 20 21 22 23 24 25
+ 26 27 28 29 30
*
- Now let's write the buffer contents to a file named `junk' with the
+ Now let's write the buffer contents to a file named 'junk' with the
<w> ("write") command. Again, we use the <,> prefix to indicate that
it's the whole buffer we want:
*,w junk
- 143
+ 137
*
Need we say? It's good practice to frequently write the buffer
contents, since unwritten changes to the buffer will be lost when we
-exit `ed'.
+exit 'ed'.
The sample sessions below illustrate some basic concepts of line
-editing with `ed'. We begin by creating a file, `sonnet', with some
-help from Shakespeare. As with the shell, all input to `ed' must be
-followed by a <newline> character. Comments begin with a `#'.
+editing with 'ed'. We begin by creating a file, 'sonnet', with some
+help from Shakespeare. As with the shell, all input to 'ed' must be
+followed by a <newline> character. Comments begin with a '#'.
$ ed
- # The `a' command is for appending text to the editor buffer.
+ # The 'a' command is for appending text to the editor buffer.
a
No more be grieved at that which thou hast done.
Roses have thorns, and filvers foutians mud.
Clouds and eclipses stain both moon and sun,
And loathsome canker lives in sweetest bud.
.
- # Entering a single period on a line returns `ed' to command mode.
- # Now write the buffer to the file `sonnet' and quit:
+ # Entering a single period on a line returns 'ed' to command mode.
+ # Now write the buffer to the file 'sonnet' and quit:
w sonnet
183
- # `ed' reports the number of characters written.
+ # 'ed' reports the number of characters written.
q
$ ls -l
total 2
-rw-rw-r-- 1 alm 183 Nov 10 01:16 sonnet
$
- In the next example, some typos are corrected in the file `sonnet'.
+ In the next example, some typos are corrected in the file 'sonnet'.
$ ed sonnet
183
- # Begin by printing the buffer to the terminal with the `p' command.
- # The `,' means ``all lines.''
+ # Begin by printing the buffer to the terminal with the 'p' command.
+ # The ',' means "all lines".
,p
No more be grieved at that which thou hast done.
Roses have thorns, and filvers foutians mud.
@@ -236,11 +235,11 @@ followed by a <newline> character. Comments begin with a `#'.
# Select line 2 for editing.
2
Roses have thorns, and filvers foutians mud.
- # Use the substitute command, `s', to replace `filvers' with `silver',
+ # Use the substitute command, 's', to replace 'filvers' with 'silver',
# and print the result.
s/filvers/silver/p
Roses have thorns, and silver foutians mud.
- # And correct the spelling of `fountains'.
+ # And correct the spelling of 'fountains'.
s/utia/untai/p
Roses have thorns, and silver fountains mud.
w sonnet
@@ -248,17 +247,17 @@ followed by a <newline> character. Comments begin with a `#'.
q
$
- Since `ed' is line-oriented, we have to tell it which line, or range
+ Since 'ed' is line-oriented, we have to tell it which line, or range
of lines we want to edit. In the above example, we do this by
specifying the line's number, or sequence in the buffer. Alternatively,
-we could have specified a unique string in the line, e.g., `/filvers/',
-where the `/'s delimit the string in question. Subsequent commands
+we could have specified a unique string in the line, e.g., '/filvers/',
+where the '/'s delimit the string in question. Subsequent commands
affect only the selected line, a.k.a. the "current" line. Portions of
that line are then replaced with the substitute command, whose syntax
-is `s/OLD/NEW/'.
+is 's/OLD/NEW/'.
- Although `ed' accepts only one command per line, the print command
-`p' is an exception, and may be appended to the end of most commands.
+ Although 'ed' accepts only one command per line, the print command
+'p' is an exception, and may be appended to the end of most commands.
In the next example, a title is added to our sonnet.
@@ -273,8 +272,8 @@ is `s/OLD/NEW/'.
Clouds and eclipses stain both moon and sun,
And loathsome canker lives in sweetest bud.
Sonnet #50
- # The title got appended to the end; we should have used `0a'
- # to append ``before the first line.''
+ # The title got appended to the end; we should have used '0a'
+ # to append "before the first line".
# Move the title to its proper place.
5m0p
Sonnet #50
@@ -290,12 +289,12 @@ is `s/OLD/NEW/'.
195
$
- When `ed' opens a file, the current line is initially set to the
-last line of that file. Similarly, the move command `m' sets the
+ When 'ed' opens a file, the current line is initially set to the
+last line of that file. Similarly, the move command 'm' sets the
current line to the last line moved.
- Related programs or routines are `vi (1)', `sed (1)', `regex (3)',
-`sh (1)'. Relevant documents are:
+ Related programs or routines are 'vi (1)', 'sed (1)', 'regex (3)',
+'sh (1)'. Relevant documents are:
Unix User's Manual Supplementary Documents: 12 -- 13
@@ -303,167 +302,170 @@ current line to the last line moved.
Addison-Wesley, 1981.

-File: ed.info, Node: Invoking Ed, Next: Line Addressing, Prev: Introduction to Line Editing, Up: Top
+File: ed.info, Node: Invoking ed, Next: Line addressing, Prev: Introduction to line editing, Up: Top
-3 Invoking Ed
+3 Invoking ed
*************
-The format for running `ed' is:
+The format for running 'ed' is:
ed [OPTIONS] [FILE]
red [OPTIONS] [FILE]
FILE specifies the name of a file to read. If FILE is prefixed with
a bang (!), then it is interpreted as a shell command. In this case,
-what is read is the standard output of FILE executed via `sh (1)'. To
+what is read is the standard output of FILE executed via 'sh (1)'. To
read a file whose name begins with a bang, prefix the name with a
-backslash (`\'). The default filename is set to FILE only if it is not
+backslash ('\'). The default filename is set to FILE only if it is not
prefixed with a bang.
- `ed' supports the following options:
+ 'ed' supports the following options:
-`-h'
-`--help'
+'-h'
+'--help'
Print an informative help message describing the options and exit.
-`-V'
-`--version'
- Print the version number of `ed' on the standard output and exit.
+'-V'
+'--version'
+ Print the version number of 'ed' on the standard output and exit.
-`-G'
-`--traditional'
+'-G'
+'--traditional'
Forces backwards compatibility. This affects the behavior of the
- `ed' commands `G', `V', `f', `l', `m', `t' and `!!'. If the
+ 'ed' commands 'G', 'V', 'f', 'l', 'm', 't' and '!!'. If the
default behavior of these commands does not seem familiar, then
- try invoking `ed' with this switch.
+ try invoking 'ed' with this switch.
-`-l'
-`--loose-exit-status'
+'-l'
+'--loose-exit-status'
Do not exit with bad status if a command happens to "fail" (for
example if a substitution command finds nothing to replace). This
- can be useful when `ed' is invoked as the editor for crontab.
+ can be useful when 'ed' is invoked as the editor for crontab.
-`-p STRING'
-`--prompt=STRING'
+'-p STRING'
+'--prompt=STRING'
Specifies a command prompt. This may be toggled on and off with the
- `P' command.
+ 'P' command.
-`-r'
-`--restricted'
+'-r'
+'--restricted'
Run in restricted mode. This mode disables edition of files out of
the current directory and execution of shell commands.
-`-s'
-`--quiet'
-`--silent'
- Suppresses diagnostics. This should be used if `ed''s standard
+'-s'
+'--quiet'
+'--silent'
+ Suppresses diagnostics. This should be used if 'ed''s standard
input is from a script.
-`-v'
-`--verbose'
- Verbose mode. This may be toggled on and off with the `H' command.
+'-v'
+'--verbose'
+ Verbose mode. This may be toggled on and off with the 'H' command.

-File: ed.info, Node: Line Addressing, Next: Regular Expressions, Prev: Invoking Ed, Up: Top
+File: ed.info, Node: Line addressing, Next: Regular expressions, Prev: Invoking ed, Up: Top
-4 Line Addressing
+4 Line addressing
*****************
-An address represents the number of a line in the buffer. `ed'
+An address represents the number of a line in the buffer. 'ed'
maintains a "current address" which is typically supplied to commands
as the default address when none is specified. When a file is first
read, the current address is set to the last line of the file. In
general, the current address is set to the last line affected by a
command.
- A line address is constructed from one of the bases in the list
-below, optionally followed by a numeric offset. The offset may include
-any combination of digits, operators (i.e., `+' and `-') and
-whitespace. Addresses are read from left to right, and their values may
-be absolute or relative to the current address.
-
One exception to the rule that addresses represent line numbers is
-the address `0' (zero). This means "before the first line," and is
+the address '0' (zero). This means "before the first line", and is
valid wherever it makes sense.
- An address range is two addresses separated either by a comma or
-semicolon. The value of the first address in a range cannot exceed the
-value of the second. If only one address is given in a range, then the
-second address is set to the given address. If an N-tuple of addresses
-is given where N > 2, then the corresponding range is determined by the
-last two addresses in the N-tuple. If only one address is expected,
-then the last address is used.
+ An address range is two addresses separated either by a comma (',')
+or a semicolon (';'). The value of the first address in a range cannot
+exceed the value of the second. If only one address is given in a
+range, then the second address is set to the given address. If an
+N-tuple of addresses is given where N > 2, then the corresponding range
+is determined by the last two addresses in the N-tuple. If only one
+address is expected, then the last address is used.
- Each address in a comma-delimited range is interpreted relative to
-the current address. In a semicolon-delimited range, the first address
-is used to set the current address, and the second address is
-interpreted relative to the first.
+ In a semicolon-delimited range, the current address ('.') is set to
+the first address before the second address is calculated. This feature
+can be used to set the starting line for searches.
- The following address symbols are recognized.
+ A line address is constructed as follows:
-`.'
+'.'
The current line (address) in the buffer.
-`$'
+'$'
The last line in the buffer.
-`N'
- The Nth, line in the buffer where N is a number in the range `0,$'.
+'N'
+ The Nth line in the buffer, where N is a number in the range '0,$'.
-`+'
- The next line. This is equivalent to `+1' and may be repeated with
- cumulative effect.
+'+N'
+ The Nth next line, where N is a non-negative number.
-`-'
- The previous line. This is equivalent to `-1' and may be repeated
- with cumulative effect.
+'-N'
+ The Nth previous line, where N is a non-negative number.
-`+N'
-`WHITESPACE N'
- The Nth next line, where N is a non-negative number. Whitespace
- followed by a number N is interpreted as `+N'.
+'+'
+ The next line. This is equivalent to '+1' and may be repeated with
+ cumulative effect.
-`-N'
- The Nth previous line, where N is a non-negative number.
+'-'
+ The previous line. This is equivalent to '-1' and may be repeated
+ with cumulative effect.
-`,'
+','
The first through last lines in the buffer. This is equivalent to
- the address range `1,$'.
+ the address range '1,$'.
-`;'
+';'
The current through last lines in the buffer. This is equivalent
- to the address range `.,$'.
+ to the address range '.,$'.
-`/RE/'
+'/RE/'
The next line containing the regular expression RE. The search
wraps to the beginning of the buffer and continues down to the
- current line, if necessary. `//' repeats the last search.
+ current line, if necessary. '//' repeats the last search.
-`?RE?'
+'?RE?'
The previous line containing the regular expression RE. The search
wraps to the end of the buffer and continues up to the current
- line, if necessary. `??' repeats the last search.
+ line, if necessary. '??' repeats the last search.
-`'x'
+''x'
The apostrophe-x character pair addresses the line previously
- marked by a `k' (mark) command, where `x' is a lower case letter
+ marked by a 'k' (mark) command, where 'x' is a lower case letter
from the portable character set.
+ Addresses can be followed by one or more address offsets, optionally
+separated by whitespace. Offsets are constructed as follows:
+
+ * A number adds the indicated number of lines to the address.
+
+ * '+' or '-' followed by a number adds or subtracts the indicated
+ number of lines to or from the address.
+
+ * '+' or '-' not followed by a number adds or subtracts 1 to or from
+ the address.
+
+

-File: ed.info, Node: Regular Expressions, Next: Commands, Prev: Line Addressing, Up: Top
+File: ed.info, Node: Regular expressions, Next: Commands, Prev: Line addressing, Up: Top
-5 Regular Expressions
+5 Regular expressions
*********************
Regular expressions are patterns used in selecting text. For example,
-the `ed' command
+the 'ed' command
g/STRING/
prints all lines containing STRING. Regular expressions are also used
-by the `s' command for selecting old text to be replaced with new text.
+by the 's' command for selecting old text to be replaced with new text.
In addition to a specifying string literals, regular expressions can
represent classes of strings. Strings thus represented are said to be
@@ -473,22 +475,22 @@ left-most longest match is the one selected.
The following symbols are used in constructing regular expressions:
-`C'
- Any character C not listed below, including `{', `}', `(', `)',
- `<' and `>', matches itself.
+'C'
+ Any character C not listed below, including '{', '}', '(', ')',
+ '<' and '>', matches itself.
-`\C'
- Any backslash-escaped character C, other than `{', ``}', `(', `)',
- `<', `>', `b', `B', `w', `W', `+' and `?', matches itself.
+'\C'
+ Any backslash-escaped character C, other than '{', '}', '(', ')',
+ '<', '>', 'b', 'B', 'w', 'W', '+' and '?', matches itself.
-`.'
+'.'
Matches any single character.
-`[CHAR-CLASS]'
- Matches any single character in CHAR-CLASS. To include a `]' in
+'[CHAR-CLASS]'
+ Matches any single character in CHAR-CLASS. To include a ']' in
CHAR-CLASS, it must be the first character. A range of characters
may be specified by separating the end characters of the range
- with a `-', e.g., `a-z' specifies the lower case characters. The
+ with a '-', e.g., 'a-z' specifies the lower case characters. The
following literal expressions can also be used in CHAR-CLASS to
specify sets of characters:
@@ -496,7 +498,7 @@ left-most longest match is the one selected.
[:alpha:] [:digit:] [:print:] [:upper:]
[:blank:] [:graph:] [:punct:] [:xdigit:]
- If `-' appears as the first or last character of CHAR-CLASS, then
+ If '-' appears as the first or last character of CHAR-CLASS, then
it matches itself. All other characters in CHAR-CLASS match
themselves.
@@ -505,362 +507,364 @@ left-most longest match is the one selected.
[=COL-ELM=]
where COL-ELM is a "collating element" are interpreted according
- to `locale (5)'. See `regex (3)' for an explanation of these
+ to 'locale (5)'. See 'regex (3)' for an explanation of these
constructs.
-`[^CHAR-CLASS]'
+'[^CHAR-CLASS]'
Matches any single character, other than newline, not in
CHAR-CLASS. CHAR-CLASS is defined as above.
-`^'
- If `^' is the first character of a regular expression, then it
+'^'
+ If '^' is the first character of a regular expression, then it
anchors the regular expression to the beginning of a line.
Otherwise, it matches itself.
-`$'
- If `$' is the last character of a regular expression, it anchors
+'$'
+ If '$' is the last character of a regular expression, it anchors
the regular expression to the end of a line. Otherwise, it matches
itself.
-`\(RE\)'
+'\(RE\)'
Defines a (possibly null) subexpression RE. Subexpressions may be
- nested. A subsequent backreference of the form `\N', where N is a
+ nested. A subsequent backreference of the form '\N', where N is a
number in the range [1,9], expands to the text matched by the Nth
- subexpression. For example, the regular expression `\(a.c\)\1'
- matches the string `abcabc', but not `abcadc'. Subexpressions are
+ subexpression. For example, the regular expression '\(a.c\)\1'
+ matches the string 'abcabc', but not 'abcadc'. Subexpressions are
ordered relative to their left delimiter.
-`*'
+'*'
Matches the single character regular expression or subexpression
- immediately preceding it zero or more times. If `*' is the first
+ immediately preceding it zero or more times. If '*' is the first
character of a regular expression or subexpression, then it matches
- itself. The `*' operator sometimes yields unexpected results. For
- example, the regular expression `b*' matches the beginning of the
- string `abbb', as opposed to the substring `bbb', since a null
+ itself. The '*' operator sometimes yields unexpected results. For
+ example, the regular expression 'b*' matches the beginning of the
+ string 'abbb', as opposed to the substring 'bbb', since a null
match is the only left-most match.
-`\{N,M\}'
-`\{N,\}'
-`\{N\}'
+'\{N,M\}'
+'\{N,\}'
+'\{N\}'
Matches the single character regular expression or subexpression
immediately preceding it at least N and at most M times. If M is
omitted, then it matches at least N times. If the comma is also
omitted, then it matches exactly N times. If any of these forms
occurs first in a regular expression or subexpression, then it is
- interpreted literally (i.e., the regular expression `\{2\}'
- matches the string `{2}', and so on).
+ interpreted literally (i.e., the regular expression '\{2\}'
+ matches the string '{2}', and so on).
-`\<'
-`\>'
+'\<'
+'\>'
Anchors the single character regular expression or subexpression
- immediately following it to the beginning (in the case of `\<') or
- ending (in the case of `\>') of a "word", i.e., in ASCII, a
+ immediately following it to the beginning (in the case of '\<') or
+ ending (in the case of '\>') of a "word", i.e., in ASCII, a
maximal string of alphanumeric characters, including the
underscore (_).
- The following extended operators are preceded by a backslash `\' to
-distinguish them from traditional `ed' syntax.
+ The following extended operators are preceded by a backslash '\' to
+distinguish them from traditional 'ed' syntax.
-`\`'
-`\''
- Unconditionally matches the beginning `\`' or ending `\'' of a
+'\`'
+'\''
+ Unconditionally matches the beginning '\`' or ending '\'' of a
line.
-`\?'
+'\?'
Optionally matches the single character regular expression or
subexpression immediately preceding it. For example, the regular
- expression `a[bd]\?c' matches the strings `abc', `adc' and `ac'.
- If `\?' occurs at the beginning of a regular expressions or
- subexpression, then it matches a literal `?'.
+ expression 'a[bd]\?c' matches the strings 'abc', 'adc' and 'ac'.
+ If '\?' occurs at the beginning of a regular expressions or
+ subexpression, then it matches a literal '?'.
-`\+'
+'\+'
Matches the single character regular expression or subexpression
immediately preceding it one or more times. So the regular
- expression `a+' is shorthand for `aa*'. If `\+' occurs at the
+ expression 'a+' is shorthand for 'aa*'. If '\+' occurs at the
beginning of a regular expression or subexpression, then it
- matches a literal `+'.
+ matches a literal '+'.
-`\b'
+'\b'
Matches the beginning or ending (null string) of a word. Thus the
- regular expression `\bhello\b' is equivalent to `\<hello\>'.
- However, `\b\b' is a valid regular expression whereas `\<\>' is
+ regular expression '\bhello\b' is equivalent to '\<hello\>'.
+ However, '\b\b' is a valid regular expression whereas '\<\>' is
not.
-`\B'
+'\B'
Matches (a null string) inside a word.
-`\w'
+'\w'
Matches any character in a word.
-`\W'
+'\W'
Matches any character not in a word.

-File: ed.info, Node: Commands, Next: Limitations, Prev: Regular Expressions, Up: Top
+File: ed.info, Node: Commands, Next: Limitations, Prev: Regular expressions, Up: Top
6 Commands
**********
-All `ed' commands are single characters, though some require additonal
+All 'ed' commands are single characters, though some require additonal
parameters. If a command's parameters extend over several lines, then
-each line except for the last must be terminated with a backslash (`\').
+each line except for the last must be terminated with a backslash ('\').
In general, at most one command is allowed per line. However, most
-commands accept a print suffix, which is any of `p' (print), `l'
-(list), or `n' (enumerate), to print the last line affected by the
+commands accept a print suffix, which is any of 'p' (print), 'l'
+(list), or 'n' (enumerate), to print the last line affected by the
command.
An interrupt (typically <Control-C>) has the effect of aborting the
current command and returning the editor to command mode.
- `ed' recognizes the following commands. The commands are shown
+ 'ed' recognizes the following commands. The commands are shown
together with the default address or address range supplied if none is
specified (in parenthesis).
-`(.)a'
+'(.)a'
Appends text to the buffer after the addressed line, which may be
- the address `0' (zero). Text is entered in input mode. The current
+ the address '0' (zero). Text is entered in input mode. The current
address is set to last line entered.
-`(.,.)c'
+'(.,.)c'
Changes lines in the buffer. The addressed lines are deleted from
the buffer, and text is appended in their place. Text is entered
in input mode. The current address is set to last line entered.
-`(.,.)d'
+'(.,.)d'
Deletes the addressed lines from the buffer. If there is a line
after the deleted range, then the current address is set to this
line. Otherwise the current address is set to the line before the
deleted range.
-`e FILE'
+'e FILE'
Edits FILE, and sets the default filename. If FILE is not
specified, then the default filename is used. Any lines in the
buffer are deleted before the new file is read. The current
address is set to the last line read.
-`e !COMMAND'
- Edits the standard output of `!COMMAND', (see the `!' command
+'e !COMMAND'
+ Edits the standard output of '!COMMAND', (see the '!' command
below). The default filename is unchanged. Any lines in the buffer
are deleted before the output of COMMAND is read. The current
address is set to the last line read.
-`E FILE'
- Edits FILE unconditionally. This is similar to the `e' command,
+'E FILE'
+ Edits FILE unconditionally. This is similar to the 'e' command,
except that unwritten changes are discarded without warning. The
current address is set to the last line read.
-`f FILE'
+'f FILE'
Sets the default filename to FILE. If FILE is not specified, then
the default unescaped filename is printed.
-`(1,$)g /RE/COMMAND-LIST'
+'(1,$)g /RE/COMMAND-LIST'
Global command. Applies COMMAND-LIST to each of the addressed
lines matching a regular expression RE. The current address is set
to the line currently matched before COMMAND-LIST is executed. At
- the end of the `g' command, the current address is set to the last
+ the end of the 'g' command, the current address is set to the last
line affected by COMMAND-LIST.
At least the first command of COMMAND-LIST must appear on the same
- line as the `g' command. All lines of a multi-line COMMAND-LIST
- except the last line must be terminated with a backslash (`\').
- Any commands are allowed, except for `g', `G', `v', and `V'. By
- default, a newline alone in COMMAND-LIST is equivalent to a `p'
- command. If `ed' is invoked with the command-line option `-G',
- then a newline in COMMAND-LIST is equivalent to a `.+1p' command.
-
-`(1,$)G /RE/'
+ line as the 'g' command. All lines of a multi-line COMMAND-LIST
+ except the last line must be terminated with a backslash ('\').
+ Any commands are allowed, except for 'g', 'G', 'v', and 'V'. By
+ default, a newline alone in COMMAND-LIST is equivalent to a 'p'
+ command. If 'ed' is invoked with the command-line option '-G',
+ then a newline in COMMAND-LIST is equivalent to a '.+1p' command.
+
+'(1,$)G /RE/'
Interactive global command. Interactively edits the addressed lines
matching a regular expression RE. For each matching line, the line
is printed, the current address is set, and the user is prompted to
- enter a COMMAND-LIST. At the end of the `G' command, the current
+ enter a COMMAND-LIST. At the end of the 'G' command, the current
address is set to the last line affected by (the last)
COMMAND-LIST.
- The format of COMMAND-LIST is the same as that of the `g' command.
- A newline alone acts as a null command list. A single `&' repeats
+ The format of COMMAND-LIST is the same as that of the 'g' command.
+ A newline alone acts as a null command list. A single '&' repeats
the last non-null command list.
-`H'
+'H'
Toggles the printing of error explanations. By default,
explanations are not printed. It is recommended that ed scripts
begin with this command to aid in debugging.
-`h'
+'h'
Prints an explanation of the last error.
-`(.)i'
- Inserts text in the buffer before the current line. The address `0'
- (zero) is valid for this command; it is equivalent to address `1'.
+'(.)i'
+ Inserts text in the buffer before the current line. The address '0'
+ (zero) is valid for this command; it is equivalent to address '1'.
Text is entered in input mode. The current address is set to the
last line entered.
-`(.,.+1)j'
+'(.,.+1)j'
Joins the addressed lines. The addressed lines are deleted from the
buffer and replaced by a single line containing their joined text.
The current address is set to the resultant line.
-`(.)kx'
- Marks a line with a lower case letter `x'. The line can then be
- addressed as `'x' (i.e., a single quote followed by `x') in
+'(.)kx'
+ Marks a line with a lower case letter 'x'. The line can then be
+ addressed as ''x' (i.e., a single quote followed by 'x') in
subsequent commands. The mark is not cleared until the line is
deleted or otherwise modified.
-`(.,.)l'
+'(.,.)l'
Prints the addressed lines unambiguously. The end of each line is
- marked with a `$', and every `$' character within the text is
+ marked with a '$', and every '$' character within the text is
printed with a preceding backslash. The current address is set to
the last line printed.
-`(.,.)m(.)'
+'(.,.)m(.)'
Moves lines in the buffer. The addressed lines are moved to after
- the right-hand destination address, which may be the address `0'
+ the right-hand destination address, which may be the address '0'
(zero). The current address is set to the new address of the last
line moved.
-`(.,.)n'
+'(.,.)n'
Prints the addressed lines, preceding each line by its line number
and a <tab>. The current address is set to the last line printed.
-`(.,.)p'
+'(.,.)p'
Prints the addressed lines. The current address is set to the last
line printed.
-`P'
+'P'
Toggles the command prompt on and off. Unless a prompt is
- specified with command-line option `-p', the command prompt is by
+ specified with command-line option '-p', the command prompt is by
default turned off.
-`q'
- Quits `ed'.
+'q'
+ Quits 'ed'.
-`Q'
- Quits `ed' unconditionally. This is similar to the `q' command,
+'Q'
+ Quits 'ed' unconditionally. This is similar to the 'q' command,
except that unwritten changes are discarded without warning.
-`($)r FILE'
+'($)r FILE'
Reads FILE to after the addressed line. If FILE is not specified,
then the default filename is used. If there is no default filename
prior to the command, then the default filename is set to FILE.
Otherwise, the default filename is unchanged. The current address
is set to the last line read.
-`($)r !COMMAND'
+'($)r !COMMAND'
Reads to after the addressed line the standard output of
- `!command', (see the `!' command below). The default filename is
+ '!command', (see the '!' command below). The default filename is
unchanged. The current address is set to the last line read.
-`(.,.)s /RE/REPLACEMENT/'
-`(.,.)s /RE/REPLACEMENT/g'
-`(.,.)s /RE/REPLACEMENT/N'
+'(.,.)s /RE/REPLACEMENT/'
+'(.,.)s /RE/REPLACEMENT/g'
+'(.,.)s /RE/REPLACEMENT/N'
Replaces text in the addressed lines matching a regular expression
RE with REPLACEMENT. By default, only the first match in each line
- is replaced. If the `g' (global) suffix is given, then every match
+ is replaced. If the 'g' (global) suffix is given, then every match
is replaced. The N suffix, where N is a postive number, causes
only the Nth match to be replaced. It is an error if no
substitutions are performed on any of the addressed lines. The
current address is set to the last line affected.
RE and REPLACEMENT may be delimited by any character other than
- <space>, <newline> and the characters used by the form of the `s'
+ <space>, <newline> and the characters used by the form of the 's'
command shown below. If one or two of the last delimiters is
omitted, then the last line affected is printed as if the print
- suffix `p' were specified.
+ suffix 'p' were specified.
- An unescaped `&' in REPLACEMENT is replaced by the currently
- matched text. The character sequence `\M' where M is a number in
+ An unescaped '&' in REPLACEMENT is replaced by the currently
+ matched text. The character sequence '\M' where M is a number in
the range [1,9], is replaced by the Mth backreference expression
- of the matched text. If REPLACEMENT consists of a single `%', then
+ of the matched text. If REPLACEMENT consists of a single '%', then
REPLACEMENT from the last substitution is used. Newlines may be
- embedded in REPLACEMENT if they are escaped with a backslash (`\').
+ embedded in REPLACEMENT if they are escaped with a backslash ('\').
-`(.,.)s'
- Repeats the last substitution. This form of the `s' command accepts
- a count suffix N, and any combination of the characters `r', `g',
- and `p'. If a count suffix N is given, then only the Nth match is
- replaced. The `r' suffix causes the regular expression of the last
+'(.,.)s'
+ Repeats the last substitution. This form of the 's' command accepts
+ a count suffix N, and any combination of the characters 'r', 'g',
+ and 'p'. If a count suffix N is given, then only the Nth match is
+ replaced. The 'r' suffix causes the regular expression of the last
search to be used instead of the that of the last substitution.
- The `g' suffix toggles the global suffix of the last substitution.
- The `p' suffix toggles the print suffix of the last substitution.
+ The 'g' suffix toggles the global suffix of the last substitution.
+ The 'p' suffix toggles the print suffix of the last substitution.
The current address is set to the last line affected.
-`(.,.)t(.)'
+'(.,.)t(.)'
Copies (i.e., transfers) the addressed lines to after the
- right-hand destination address, which may be the address `0'
+ right-hand destination address, which may be the address '0'
(zero). The current address is set to the last line copied.
-`u'
+'u'
Undoes the last command and restores the current address to what
- it was before the command. The global commands `g', `G', `v', and
- `V' are treated as a single command by undo. `u' is its own
+ it was before the command. The global commands 'g', 'G', 'v', and
+ 'V' are treated as a single command by undo. 'u' is its own
inverse.
-`(1,$)v /RE/COMMAND-LIST'
- This is similar to the `g' command except that it applies
+'(1,$)v /RE/COMMAND-LIST'
+ This is similar to the 'g' command except that it applies
COMMAND-LIST to each of the addressed lines not matching the
regular expression RE.
-`(1,$)V /RE/'
- This is similar to the `G' command except that it interactively
+'(1,$)V /RE/'
+ This is similar to the 'G' command except that it interactively
edits the addressed lines not matching the regular expression RE.
-`(1,$)w FILE'
+'(1,$)w FILE'
Writes the addressed lines to FILE. Any previous contents of FILE
is lost without warning. If there is no default filename, then the
default filename is set to FILE, otherwise it is unchanged. If no
filename is specified, then the default filename is used. The
current address is unchanged.
-`(1,$)w !COMMAND'
- Writes the addressed lines to the standard input of `!COMMAND',
- (see the `!' command below). The default filename and current
+'(1,$)w !COMMAND'
+ Writes the addressed lines to the standard input of '!COMMAND',
+ (see the '!' command below). The default filename and current
address are unchanged.
-`(1,$)wq FILE'
- Writes the addressed lines to FILE, and then executes a `q'
+'(1,$)wq FILE'
+ Writes the addressed lines to FILE, and then executes a 'q'
command.
-`(1,$)W FILE'
+'(1,$)W FILE'
Appends the addressed lines to the end of FILE. This is similar to
- the `w' command, expect that the previous contents of file is not
+ the 'w' command, expect that the previous contents of file is not
clobbered. The current address is unchanged.
-`(.)x'
+'(.)x'
Copies (puts) the contents of the cut buffer to after the addressed
line. The current address is set to the last line copied.
-`(.,.)y'
+'(.,.)y'
Copies (yanks) the addressed lines to the cut buffer. The cut
- buffer is overwritten by subsequent `y', `s', `j', `d', or `c'
+ buffer is overwritten by subsequent 'y', 's', 'j', 'd', or 'c'
commands. The current address is unchanged.
-`(.+1)z N'
- Scrolls N lines at a time starting at addressed line. If N is not
- specified, then the current window size is used. The current
- address is set to the last line printed.
-
-`!COMMAND'
- Executes COMMAND via `sh (1)'. If the first character of COMMAND
- is `!', then it is replaced by text of the previous `!COMMAND'.
- `ed' does not process COMMAND for backslash (`\') escapes.
- However, an unescaped `%' is replaced by the default filename.
- When the shell returns from execution, a `!' is printed to the
+'(.+1)z N'
+ Scrolls N lines at a time starting at addressed line, and sets
+ window size to N. If N is not specified, then the current window
+ size is used. Window size defaults to screen size minus two lines,
+ or to 22 if screen size can't be determined. The current address
+ is set to the last line printed.
+
+'!COMMAND'
+ Executes COMMAND via 'sh (1)'. If the first character of COMMAND
+ is '!', then it is replaced by text of the previous '!COMMAND'.
+ 'ed' does not process COMMAND for backslash ('\') escapes.
+ However, an unescaped '%' is replaced by the default filename.
+ When the shell returns from execution, a '!' is printed to the
standard output. The current line is unchanged.
-`(.,.)#'
+'(.,.)#'
Begins a comment; the rest of the line, up to a newline, is
ignored. If a line address followed by a semicolon is given, then
the current address is set to that address. Otherwise, the current
address is unchanged.
-`($)='
+'($)='
Prints the line number of the addressed line.
-`(.+1)<newline>'
+'(.+1)<newline>'
An address alone prints the addressed line. A <newline> alone is
- equivalent to `+1p'. the current address is set to the address of
+ equivalent to '+1p'. the current address is set to the address of
the printed line.
@@ -870,18 +874,18 @@ File: ed.info, Node: Limitations, Next: Diagnostics, Prev: Commands, Up: Top
7 Limitations
*************
-If the terminal hangs up, `ed' attempts to write the buffer to file
-`ed.hup' or, if this fails, to `$HOME/ed.hup'.
+If the terminal hangs up, 'ed' attempts to write the buffer to file
+'ed.hup' or, if this fails, to '$HOME/ed.hup'.
- `ed' processes FILE arguments for backslash escapes, i.e., in a
-filename, any character preceded by a backslash (`\') is interpreted
+ 'ed' processes FILE arguments for backslash escapes, i.e., in a
+filename, any character preceded by a backslash ('\') is interpreted
literally.
If a text (non-binary) file is not terminated by a newline character,
-then `ed' appends one on reading/writing it. In the case of a binary
-file, `ed' does not append a newline on reading/writing.
+then 'ed' appends one on reading/writing it. In the case of a binary
+file, 'ed' does not append a newline on reading/writing.
- Per line overhead: 2 `pointer's, 1 `long int', and 1 `int'.
+ Per line overhead: 2 'pointer's, 1 'long int', and 1 'int'.

File: ed.info, Node: Diagnostics, Next: Problems, Prev: Limitations, Up: Top
@@ -889,34 +893,34 @@ File: ed.info, Node: Diagnostics, Next: Problems, Prev: Limitations, Up: Top
8 Diagnostics
*************
-When an error occurs, if `ed''s input is from a regular file or here
-document, then it exits, otherwise it prints a `?' and returns to
+When an error occurs, if 'ed''s input is from a regular file or here
+document, then it exits, otherwise it prints a '?' and returns to
command mode. An explanation of the last error can be printed with the
-`h' (help) command.
+'h' (help) command.
- If the `u' (undo) command occurs in a global command list, then the
+ If the 'u' (undo) command occurs in a global command list, then the
command list is executed only once.
- Attempting to quit `ed' or edit another file before writing a
+ Attempting to quit 'ed' or edit another file before writing a
modified buffer results in an error. If the command is entered a second
time, it succeeds, but any changes to the buffer are lost.
- `ed' exits with 0 if no errors occurred; otherwise >0.
+ Exit status: 0 if no errors occurred; otherwise >0.

File: ed.info, Node: Problems, Next: GNU Free Documentation License, Prev: Diagnostics, Up: Top
-9 Reporting Bugs
+9 Reporting bugs
****************
-There are probably bugs in `ed'. There are certainly errors and
+There are probably bugs in 'ed'. There are certainly errors and
omissions in this manual. If you report them, they will get fixed. If
you don't, no one will ever know about them and they will remain unfixed
for all eternity, if not longer.
- If you find a bug in `ed', please send electronic mail to
+ If you find a bug in 'ed', please send electronic mail to
<bug-ed@gnu.org>. Include the version number, which you can find by
-running ``ed' --version'.
+running 'ed --version'.

File: ed.info, Node: GNU Free Documentation License, Prev: Problems, Up: Top
@@ -927,7 +931,7 @@ File: ed.info, Node: GNU Free Documentation License, Prev: Problems, Up: Top
Version 1.3, 3 November 2008
Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
- `http://fsf.org/'
+ 'http://fsf.org/'
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@@ -1327,7 +1331,7 @@ File: ed.info, Node: GNU Free Documentation License, Prev: Problems, Up: Top
the GNU Free Documentation License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns. See
- `http://www.gnu.org/copyleft/'.
+ 'http://www.gnu.org/copyleft/'.
Each version of the License is given a distinguishing version
number. If the Document specifies that a particular numbered
@@ -1407,17 +1411,17 @@ permit their use in free software.

Tag Table:
-Node: Top568
-Node: Overview2247
-Node: Introduction to Line Editing4304
-Node: Invoking Ed11516
-Node: Line Addressing13317
-Node: Regular Expressions16420
-Node: Commands21765
-Node: Limitations32910
-Node: Diagnostics33551
-Node: Problems34255
-Node: GNU Free Documentation License34790
+Node: Top535
+Node: Overview2193
+Node: Introduction to line editing4250
+Node: Invoking ed11491
+Node: Line addressing13292
+Node: Regular expressions16369
+Node: Commands21713
+Node: Limitations32993
+Node: Diagnostics33634
+Node: Problems34335
+Node: GNU Free Documentation License34868

End Tag Table
diff --git a/doc/ed.texinfo b/doc/ed.texi
index 0cbd524..6afc69c 100644
--- a/doc/ed.texinfo
+++ b/doc/ed.texi
@@ -6,8 +6,8 @@
@finalout
@c %**end of header
-@set UPDATED 1 January 2012
-@set VERSION 1.6
+@set UPDATED 30 March 2015
+@set VERSION 1.11
@dircategory Basics
@direntry
@@ -15,8 +15,8 @@
@end direntry
@copying
-Copyright @copyright{} 1993, 1994, 2006, 2007, 2008, 2009, 2010, 2011,
-2012 Free Software Foundation, Inc.
+Copyright @copyright{} 1993, 1994, 2006-2015
+Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -56,17 +56,16 @@ superseded by full-screen editors such as GNU Emacs or GNU Moe.
@end ifnottex
@menu
-* Overview:: Overview of the @command{ed} command
-* Introduction to Line Editing:: Getting started with GNU @command{ed}
-* Invoking Ed:: Command line interface
-* Line Addressing:: Specifying lines/ranges in the buffer
-* Regular Expressions:: Patterns for selecting text
-* Commands:: Commands recognized by GNU @command{ed}
-* Limitations:: Intrinsic limits of GNU @command{ed}
-* Diagnostics:: GNU @command{ed} error handling
-* Problems:: Reporting bugs
-* GNU Free Documentation License:: How you can copy and share this manual
-
+* Overview:: Overview of the @command{ed} command
+* Introduction to line editing:: Getting started with GNU @command{ed}
+* Invoking ed:: Command line interface
+* Line addressing:: Specifying lines/ranges in the buffer
+* Regular expressions:: Patterns for selecting text
+* Commands:: Commands recognized by GNU @command{ed}
+* Limitations:: Intrinsic limits of GNU @command{ed}
+* Diagnostics:: GNU @command{ed} error handling
+* Problems:: Reporting bugs
+* GNU Free Documentation License:: How you can copy and share this manual
@end menu
@sp 1
@@ -124,19 +123,26 @@ by the command. If fewer addresses are given than the command accepts,
then default addresses are supplied.
-@node Introduction to Line Editing
-@chapter Introduction to Line Editing
+@node Introduction to line editing
+@chapter Introduction to line editing
@command{ed} was created, along with the Unix operating system, by Ken
Thompson and Dennis Ritchie. It is the refinement of its more complex,
programmable predecessor, @cite{QED}, to which Thompson and Ritchie had
already added pattern matching capabilities (@pxref{Regular
-Expressions}).
+expressions}).
For the purposes of this tutorial, a working knowledge of the Unix shell
-@command{sh} (@pxref{Bash,,, bash, The GNU Bash Reference Manual}) and
-the Unix file system is recommended, since @command{ed} is designed to
-interact closely with them.
+@command{sh} and the Unix file system is recommended, since @command{ed}
+is designed to interact closely with them.
+@ifnothtml
+(@xref{Top,GNU bash manual,,bash},
+@end ifnothtml
+@ifhtml
+(See the
+@uref{http://www.gnu.org/software/bash/manual/,,bash manual}
+@end ifhtml
+for details about bash).
The principal difference between line editors and display editors is
that display editors provide instant feedback to user commands, whereas
@@ -150,7 +156,7 @@ Much of the @command{ed} command syntax is shared with other Unix
utilities.
As with the shell, @key{RETURN} (the carriage-return key) enters a line
-of input. So when we speak of ``entering'' a command or some text in
+of input. So when we speak of "entering" a command or some text in
@command{ed}, @key{RETURN} is implied at the end of each line. Prior to
typing @key{RETURN}, corrections to the line may be made by typing
either @key{BACKSPACE} (sometimes labeled @key{DELETE} or @key{DEL}) to
@@ -171,7 +177,7 @@ By default, @command{ed} uses asterisk (@samp{*}) as command prompt to
avoid confusion with the shell command prompt (@samp{$}).
We can run Unix shell (@command{sh}) commands from inside @command{ed}
-by prefixing them with @key{!} (exclamation mark, aka ``bang''). For
+by prefixing them with @key{!} (exclamation mark, aka "bang"). For
example:
@example
@@ -192,28 +198,28 @@ called a @dfn{buffer} where @command{ed} can access it. This is done
with @command{ed}'s @key{r} command (mnemonic: @dfn{read}):
@example
-*r !cal
-143
+*r !cal -m
+137
*
@end example
-Here @command{ed} is telling us that it has just read 143 characters
+Here @command{ed} is telling us that it has just read 137 characters
into the editor buffer - i.e., the output of the @command{cal} command,
which prints a simple ASCII calendar. To display the buffer contents we
issue the @key{p} (@dfn{print}) command (not to be confused with the
prompt command, which is uppercase!). To indicate the range of lines in
the buffer that should be printed, we prefix the command with @key{,}
-(comma) which is shorthand for ``the whole buffer'':
+(comma) which is shorthand for "the whole buffer":
@example
*,p
- September 2006
+ June 2006
Mo Tu We Th Fr Sa Su
- 1 2 3
- 4 5 6 7 8 9 10
-11 12 13 14 15 16 17
-18 19 20 21 22 23 24
-25 26 27 28 29 30
+ 1 2 3 4
+ 5 6 7 8 9 10 11
+12 13 14 15 16 17 18
+19 20 21 22 23 24 25
+26 27 28 29 30
*
@end example
@@ -224,7 +230,7 @@ indicate that it's the whole buffer we want:
@example
*,w junk
-143
+137
*
@end example
@@ -239,7 +245,7 @@ be followed by a @key{newline} character. Comments begin with a @samp{#}.
@example
$ ed
-# The `a' command is for appending text to the editor buffer.
+# The 'a' command is for appending text to the editor buffer.
a
No more be grieved at that which thou hast done.
Roses have thorns, and filvers foutians mud.
@@ -264,7 +270,7 @@ In the next example, some typos are corrected in the file @samp{sonnet}.
$ ed sonnet
183
# Begin by printing the buffer to the terminal with the @samp{p} command.
-# The `,' means ``all lines.''
+# The ',' means "all lines".
,p
No more be grieved at that which thou hast done.
Roses have thorns, and filvers foutians mud.
@@ -273,11 +279,11 @@ And loathsome canker lives in sweetest bud.
# Select line 2 for editing.
2
Roses have thorns, and filvers foutians mud.
-# Use the substitute command, @samp{s}, to replace `filvers' with `silver',
+# Use the substitute command, @samp{s}, to replace 'filvers' with 'silver',
# and print the result.
s/filvers/silver/p
Roses have thorns, and silver foutians mud.
-# And correct the spelling of `fountains'.
+# And correct the spelling of 'fountains'.
s/utia/untai/p
Roses have thorns, and silver fountains mud.
w sonnet
@@ -313,8 +319,8 @@ Roses have thorns, and silver fountains mud.
Clouds and eclipses stain both moon and sun,
And loathsome canker lives in sweetest bud.
Sonnet #50
-# The title got appended to the end; we should have used `0a'
-# to append ``before the first line.''
+# The title got appended to the end; we should have used '0a'
+# to append "before the first line".
# Move the title to its proper place.
5m0p
Sonnet #50
@@ -344,13 +350,13 @@ Unix User's Manual Supplementary Documents: 12 --- 13
@end quotation
@quotation
-B. W. Kernighan and P. J. Plauger: ``Software Tools in Pascal'',
+B. W. Kernighan and P. J. Plauger: "Software Tools in Pascal",
Addison-Wesley, 1981.
@end quotation
-@node Invoking Ed
-@chapter Invoking Ed
+@node Invoking ed
+@chapter Invoking ed
The format for running @command{ed} is:
@@ -413,8 +419,8 @@ Verbose mode. This may be toggled on and off with the @samp{H} command.
@end table
-@node Line Addressing
-@chapter Line Addressing
+@node Line addressing
+@chapter Line addressing
An address represents the number of a line in the buffer. @command{ed}
maintains a @dfn{current address} which is typically supplied to
@@ -423,30 +429,24 @@ first read, the current address is set to the last line of the file. In
general, the current address is set to the last line affected by a
command.
-A line address is constructed from one of the bases in the list below,
-optionally followed by a numeric offset. The offset may include any
-combination of digits, operators (i.e., @samp{+} and @samp{-}) and
-whitespace. Addresses are read from left to right, and their values may
-be absolute or relative to the current address.
-
One exception to the rule that addresses represent line numbers is the
-address @samp{0} (zero). This means ``before the first line,'' and is
+address @samp{0} (zero). This means "before the first line", and is
valid wherever it makes sense.
-An address range is two addresses separated either by a comma or
-semicolon. The value of the first address in a range cannot exceed the
-value of the second. If only one address is given in a range, then the
-second address is set to the given address. If an @var{n}-tuple of
-addresses is given where @var{n} > 2, then the corresponding range is
-determined by the last two addresses in the @var{n}-tuple. If only one
-address is expected, then the last address is used.
+An address range is two addresses separated either by a comma (@samp{,})
+or a semicolon (@samp{;}). The value of the first address in a range
+cannot exceed the value of the second. If only one address is given in a
+range, then the second address is set to the given address. If an
+@var{n}-tuple of addresses is given where @var{n} > 2, then the
+corresponding range is determined by the last two addresses in the
+@var{n}-tuple. If only one address is expected, then the last address is
+used.
-Each address in a comma-delimited range is interpreted relative to the
-current address. In a semicolon-delimited range, the first address is
-used to set the current address, and the second address is interpreted
-relative to the first.
+In a semicolon-delimited range, the current address (@samp{.}) is set to
+the first address before the second address is calculated. This feature
+can be used to set the starting line for searches.
-The following address symbols are recognized.
+A line address is constructed as follows:
@table @code
@item .
@@ -456,9 +456,15 @@ The current line (address) in the buffer.
The last line in the buffer.
@item @var{n}
-The @var{n}th, line in the buffer where @var{n} is a number in the range
+The @var{n}th line in the buffer, where @var{n} is a number in the range
@samp{0,$}.
+@item +@var{n}
+The @var{n}th next line, where @var{n} is a non-negative number.
+
+@item -@var{n}
+The @var{n}th previous line, where @var{n} is a non-negative number.
+
@item +
The next line. This is equivalent to @samp{+1} and may be repeated with
cumulative effect.
@@ -467,15 +473,6 @@ cumulative effect.
The previous line. This is equivalent to @samp{-1} and may be repeated
with cumulative effect.
-@item +@var{n}
-@itemx @var{whitespace} @var{n}
-The @var{n}th next line, where @var{n} is a non-negative number.
-Whitespace followed by a number @var{n} is interpreted as
-@samp{+@var{n}}.
-
-@item -@var{n}
-The @var{n}th previous line, where @var{n} is a non-negative number.
-
@item ,
The first through last lines in the buffer. This is equivalent to the
address range @samp{1,$}.
@@ -501,9 +498,26 @@ the portable character set.
@end table
+Addresses can be followed by one or more address offsets, optionally
+separated by whitespace. Offsets are constructed as follows:
+
+@itemize @bullet
+@item
+A number adds the indicated number of lines to the address.
+
+@item
+@samp{+} or @samp{-} followed by a number adds or subtracts the
+indicated number of lines to or from the address.
+
+@item
+@samp{+} or @samp{-} not followed by a number adds or subtracts 1 to or
+from the address.
+
+@end itemize
+
-@node Regular Expressions
-@chapter Regular Expressions
+@node Regular expressions
+@chapter Regular expressions
Regular expressions are patterns used in selecting text. For example,
the @command{ed} command
@@ -533,7 +547,7 @@ Any character @var{c} not listed below, including @samp{@{}, @samp{@}},
@item \@var{c}
Any backslash-escaped character @var{c}, other than @samp{@{},
-`@samp{@}}, @samp{(}, @samp{)}, @samp{<}, @samp{>}, @samp{b}, @samp{B},
+@samp{@}}, @samp{(}, @samp{)}, @samp{<}, @samp{>}, @samp{b}, @samp{B},
@samp{w}, @samp{W}, @samp{+} and @samp{?}, matches itself.
@item .
@@ -905,9 +919,11 @@ overwritten by subsequent @samp{y}, @samp{s}, @samp{j}, @samp{d}, or
@samp{c} commands. The current address is unchanged.
@item (.+1)z @var{n}
-Scrolls @var{n} lines at a time starting at addressed line. If @var{n}
-is not specified, then the current window size is used. The current
-address is set to the last line printed.
+Scrolls @var{n} lines at a time starting at addressed line, and sets
+window size to @var{n}. If @var{n} is not specified, then the current
+window size is used. Window size defaults to screen size minus two
+lines, or to 22 if screen size can't be determined. The current address
+is set to the last line printed.
@item !@var{command}
Executes @var{command} via @command{sh (1)}. If the first character of
@@ -967,11 +983,11 @@ Attempting to quit @command{ed} or edit another file before writing a
modified buffer results in an error. If the command is entered a second
time, it succeeds, but any changes to the buffer are lost.
-@command{ed} exits with 0 if no errors occurred; otherwise >0.
+Exit status: 0 if no errors occurred; otherwise >0.
@node Problems
-@chapter Reporting Bugs
+@chapter Reporting bugs
There are probably bugs in @command{ed}. There are certainly errors and
omissions in this manual. If you report them, they will get fixed. If
@@ -980,11 +996,11 @@ for all eternity, if not longer.
If you find a bug in @command{ed}, please send electronic mail to
@email{bug-ed@@gnu.org}. Include the version number, which you can
-find by running @w{@samp{@command{ed} --version}}.
+find by running @w{@code{ed --version}}.
@node GNU Free Documentation License
@chapter GNU Free Documentation License
-@include fdl.texinfo
+@include fdl.texi
@bye
diff --git a/doc/fdl.texinfo b/doc/fdl.texi
index 8805f1a..8805f1a 100644
--- a/doc/fdl.texinfo
+++ b/doc/fdl.texi
diff --git a/ed.h b/ed.h
index 9c16cee..ab94047 100644
--- a/ed.h
+++ b/ed.h
@@ -1,12 +1,11 @@
/* Global declarations for the ed editor. */
/* GNU ed - The GNU line editor.
Copyright (C) 1993, 1994 Andrew Moore, Talke Studio
- Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012
- Free Software Foundation, Inc.
+ Copyright (C) 2006-2015 Antonio Diaz Diaz.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
+ the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/global.c b/global.c
index c817268..5e7def6 100644
--- a/global.c
+++ b/global.c
@@ -1,12 +1,11 @@
/* global.c: global command routines for the ed line editor */
/* GNU ed - The GNU line editor.
Copyright (C) 1993, 1994 Andrew Moore, Talke Studio
- Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012
- Free Software Foundation, Inc.
+ Copyright (C) 2006-2015 Antonio Diaz Diaz.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
+ the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -60,7 +59,8 @@ bool set_active_node( const line_t * const lp )
if( !resize_line_buffer( &active_list, &active_size,
( active_len + 1 ) * sizeof (line_t **) ) )
{
- show_strerror( 0, errno ); set_error_msg( "Memory exhausted" );
+ show_strerror( 0, errno );
+ set_error_msg( "Memory exhausted" );
enable_interrupts();
return false;
}
diff --git a/io.c b/io.c
index 68956e1..548e7d3 100644
--- a/io.c
+++ b/io.c
@@ -1,12 +1,11 @@
/* io.c: i/o routines for the ed line editor */
/* GNU ed - The GNU line editor.
Copyright (C) 1993, 1994 Andrew Moore, Talke Studio
- Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012
- Free Software Foundation, Inc.
+ Copyright (C) 2006-2015 Antonio Diaz Diaz.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
+ the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -128,36 +127,37 @@ bool get_extended_line( const char ** const ibufpp, int * const lenp,
/* Read a line of text from stdin.
- Return pointer to buffer and line size (uncluding trailing newline
+ Returns pointer to buffer and line size (including trailing newline
if it exists) */
const char * get_tty_line( int * const sizep )
{
static char * buf = 0;
static int bufsz = 0;
- int i = 0, oi = -1;
+ int i = 0;
while( true )
{
const int c = getchar();
+ if( !resize_buffer( &buf, &bufsz, i + 2 ) )
+ { if( sizep ) *sizep = 0; return 0; }
if( c == EOF )
{
if( ferror( stdin ) )
{
- show_strerror( "stdin", errno ); set_error_msg( "Cannot read stdin" );
+ show_strerror( "stdin", errno );
+ set_error_msg( "Cannot read stdin" );
clearerr( stdin ); if( sizep ) *sizep = 0;
return 0;
}
- else
+ if( feof( stdin ) )
{
- clearerr( stdin ); if( i != oi ) { oi = i; continue; }
- if( i ) buf[i] = 0; if( sizep ) *sizep = i;
+ clearerr( stdin );
+ buf[i] = 0; if( sizep ) *sizep = i;
return buf;
}
}
else
{
- if( !resize_buffer( &buf, &bufsz, i + 2 ) )
- { if( sizep ) *sizep = 0; return 0; }
buf[i++] = c; if( !c ) set_binary(); if( c != '\n' ) continue;
buf[i] = 0; if( sizep ) *sizep = i;
return buf;
@@ -167,7 +167,7 @@ const char * get_tty_line( int * const sizep )
/* Read a line of text from a stream.
- Return pointer to buffer and line size (uncluding trailing newline
+ Returns pointer to buffer and line size (including trailing newline
if it exists and is not added now) */
static const char * read_stream_line( FILE * const fp, int * const sizep,
bool * const newline_added_nowp )
diff --git a/main.c b/main.c
index 27ff412..de223c0 100644
--- a/main.c
+++ b/main.c
@@ -1,10 +1,9 @@
/* GNU ed - The GNU line editor.
- Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012
- Free Software Foundation, Inc.
+ Copyright (C) 2006-2015 Antonio Diaz Diaz.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
+ the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -16,7 +15,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
- Return values: 0 for a normal exit, 1 for environmental problems
+ Exit status: 0 for a normal exit, 1 for environmental problems
(file not found, invalid flags, I/O errors, etc), 2 to indicate a
corrupt or invalid input file, 3 for an internal consistency error
(eg, bug) which caused ed to panic.
@@ -26,7 +25,7 @@
*
* This program is based on the editor algorithm described in
* Brian W. Kernighan and P. J. Plauger's book "Software Tools
- * in Pascal," Addison-Wesley, 1981.
+ * in Pascal", Addison-Wesley, 1981.
*
* The buffering algorithm is attributed to Rodney Ruddock of
* the University of Guelph, Guelph, Ontario.
@@ -45,7 +44,7 @@
static const char * const Program_name = "GNU Ed";
static const char * const program_name = "ed";
-static const char * const program_year = "2012";
+static const char * const program_year = "2015";
static const char * invocation_name = 0;
static bool restricted_ = false; /* if set, run in restricted mode */
@@ -71,9 +70,13 @@ static void show_help( void )
" -r, --restricted run in restricted mode\n"
" -s, --quiet, --silent suppress diagnostics\n"
" -v, --verbose be verbose\n"
- "Start edit by reading in `file' if given.\n"
- "If `file' begins with a `!', read output of shell command.\n"
- "\nReport bugs to <bug-ed@gnu.org>.\n"
+ "Start edit by reading in 'file' if given.\n"
+ "If 'file' begins with a '!', read output of shell command.\n"
+ "\nExit status: 0 for a normal exit, 1 for environmental problems (file\n"
+ "not found, invalid flags, I/O errors, etc), 2 to indicate a corrupt or\n"
+ "invalid input file, 3 for an internal consistency error (eg, bug) which\n"
+ "caused ed to panic.\n"
+ "\nReport bugs to bug-ed@gnu.org\n"
"Ed home page: http://www.gnu.org/software/ed/ed.html\n"
"General help using GNU software: http://www.gnu.org/gethelp\n" );
}
@@ -81,9 +84,9 @@ static void show_help( void )
static void show_version( void )
{
- printf( "%s %s\n", Program_name, PROGVERSION );
+ printf( "GNU %s %s\n", program_name, PROGVERSION );
printf( "Copyright (C) 1994 Andrew L. Moore.\n"
- "Copyright (C) %s Free Software Foundation, Inc.\n", program_year );
+ "Copyright (C) %s Antonio Diaz Diaz.\n", program_year );
printf( "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n"
"This is free software: you are free to change and redistribute it.\n"
"There is NO WARRANTY, to the extent permitted by law.\n" );
@@ -109,8 +112,9 @@ static void show_error( const char * const msg, const int errcode, const bool he
if( errcode > 0 ) fprintf( stderr, ": %s", strerror( errcode ) );
fprintf( stderr, "\n" );
}
- if( help && invocation_name && invocation_name[0] )
- fprintf( stderr, "Try `%s --help' for more information.\n", invocation_name );
+ if( help )
+ fprintf( stderr, "Try '%s --help' for more information.\n",
+ invocation_name );
}
@@ -152,12 +156,12 @@ int main( const int argc, const char * const argv[] )
{ 0 , 0, ap_no } };
struct Arg_parser parser;
+ invocation_name = argv[0];
if( !ap_init( &parser, argc, argv, options, 0 ) )
{ show_error( "Memory exhausted.", 0, false ); return 1; }
if( ap_error( &parser ) ) /* bad option */
{ show_error( ap_error( &parser ), 0, true ); return 1; }
- invocation_name = argv[0];
for( argind = 0; argind < ap_arguments( &parser ); ++argind )
{
diff --git a/main_loop.c b/main_loop.c
index fedfff5..2081b38 100644
--- a/main_loop.c
+++ b/main_loop.c
@@ -1,11 +1,10 @@
/* GNU ed - The GNU line editor.
Copyright (C) 1993, 1994 Andrew Moore, Talke Studio
- Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012
- Free Software Foundation, Inc.
+ Copyright (C) 2006-2015 Antonio Diaz Diaz.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
+ the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -92,7 +91,7 @@ static int get_marked_node_addr( int c )
}
-/* Return pointer to copy of shell command in the command buffer */
+/* Returns pointer to copy of shell command in the command buffer */
static const char * get_shell_command( const char ** const ibufpp )
{
static char * buf = 0;
@@ -159,7 +158,7 @@ static const char * skip_blanks( const char * p )
}
-/* Return pointer to copy of filename in the command buffer */
+/* Returns pointer to copy of filename in the command buffer */
static const char * get_filename( const char ** const ibufpp )
{
static char * buf = 0;
@@ -198,7 +197,7 @@ static int next_addr( const char ** const ibufpp, int * const addr_cnt )
{
const char * const s = *ibufpp = skip_blanks( *ibufpp );
int addr = current_addr();
- bool first = true;
+ bool first = true; /* true == addr, false == offset */
while( true )
{
@@ -259,7 +258,7 @@ static int next_addr( const char ** const ibufpp, int * const addr_cnt )
/* get line addresses from the command buffer until an invalid address
- is seen. Return number of addresses read */
+ is seen. Returns the number of addresses read */
static int extract_addr_range( const char ** const ibufpp )
{
int addr;
@@ -601,8 +600,9 @@ static int exec_command( const char ** const ibufpp, const int prev_status,
{ if( parse_int( &n, *ibufpp, ibufpp ) ) set_window_lines( n );
else return ERR; }
if( !get_command_suffix( ibufpp, &gflags ) ||
- !display_lines( second_addr, min( last_addr(), second_addr + window_lines() ),
- gflags ) )
+ !display_lines( second_addr,
+ min( last_addr(), second_addr + window_lines() - 1 ),
+ gflags ) )
return ERR;
gflags = 0;
break;
@@ -644,7 +644,7 @@ static bool exec_global( const char ** const ibufpp, const int gflags,
if( !interactive )
{
if( traditional() && !strcmp( *ibufpp, "\n" ) )
- cmd = "p\n"; /* null cmd_list == `p' */
+ cmd = "p\n"; /* null cmd_list == 'p' */
else
{
if( !get_extended_line( ibufpp, 0, false ) ) return false;
diff --git a/regex.c b/regex.c
index d66b20a..4a5f2b3 100644
--- a/regex.c
+++ b/regex.c
@@ -1,12 +1,11 @@
/* regex.c: regular expression interface routines for the ed line editor. */
/* GNU ed - The GNU line editor.
Copyright (C) 1993, 1994 Andrew Moore, Talke Studio
- Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012
- Free Software Foundation, Inc.
+ Copyright (C) 2006-2015 Antonio Diaz Diaz.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
+ the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/signal.c b/signal.c
index 4256ca4..18a3873 100644
--- a/signal.c
+++ b/signal.c
@@ -1,12 +1,11 @@
/* signal.c: signal and miscellaneous routines for the ed line editor. */
/* GNU ed - The GNU line editor.
Copyright (C) 1993, 1994 Andrew Moore, Talke Studio
- Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012
- Free Software Foundation, Inc.
+ Copyright (C) 2006-2015 Antonio Diaz Diaz.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
+ the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -34,7 +33,7 @@
jmp_buf jmp_state;
static int mutex = 0; /* If > 0, signals stay pending */
-static int window_lines_ = 22; /* scroll length: ws_row - 2 */
+static int window_lines_ = 22; /* scroll lines set by sigwinch_handler */
static int window_columns_ = 72;
static bool sighup_pending = false;
static bool sigint_pending = false;
@@ -42,7 +41,7 @@ static bool sigint_pending = false;
static void sighup_handler( int signum )
{
- signum = 0; /* keep compiler happy */
+ if( signum ) {} /* keep compiler happy */
if( mutex ) sighup_pending = true;
else
{
@@ -56,14 +55,14 @@ static void sighup_handler( int signum )
const int need_slash = ( ( !len || s[len-1] != '/' ) ? 1 : 0 );
char * const hup = ( ( len + need_slash + (int)sizeof hb < path_max( 0 ) ) ?
(char *) malloc( len + need_slash + sizeof hb ) : 0 );
- if( len && hup ) /* hup filename */
+ if( len && hup ) /* hup filename */
{
memcpy( hup, s, len );
if( need_slash ) hup[len] = '/';
memcpy( hup + len + need_slash, hb, sizeof hb );
if( write_file( hup, "w", 1, last_addr() ) >= 0 ) exit( 0 );
}
- exit( 1 ); /* hup file write failed */
+ exit( 1 ); /* hup file write failed */
}
exit( 0 );
}
@@ -88,7 +87,7 @@ static void sigint_handler( int signum )
static void sigwinch_handler( int signum )
{
#ifdef TIOCGWINSZ
- struct winsize ws; /* window size structure */
+ struct winsize ws; /* window size structure */
if( ioctl( 0, TIOCGWINSZ, (char *) &ws ) >= 0 )
{
@@ -97,11 +96,11 @@ static void sigwinch_handler( int signum )
if( ws.ws_col > 8 && ws.ws_col < 1800 ) window_columns_ = ws.ws_col - 8;
}
#endif
- signum = 0; /* keep compiler happy */
+ if( signum ) {} /* keep compiler happy */
}
-static int set_signal( int signum, void (*handler)( int ) )
+static int set_signal( const int signum, void (*handler)( int ) )
{
struct sigaction new_action;
@@ -172,7 +171,7 @@ bool parse_int( int * const i, const char * const str, const char ** const tail
}
-/* assure at least a minimum size for buffer `buf' */
+/* assure at least a minimum size for buffer 'buf' */
bool resize_buffer( char ** const buf, int * const size, const int min_size )
{
if( *size < min_size )
@@ -197,7 +196,7 @@ bool resize_buffer( char ** const buf, int * const size, const int min_size )
}
-/* assure at least a minimum size for buffer `buf' */
+/* assure at least a minimum size for buffer 'buf' */
bool resize_line_buffer( const line_t *** const buf, int * const size,
const int min_size )
{
@@ -223,7 +222,7 @@ bool resize_line_buffer( const line_t *** const buf, int * const size,
}
-/* assure at least a minimum size for buffer `buf' */
+/* assure at least a minimum size for buffer 'buf' */
bool resize_undo_buffer( undo_t ** const buf, int * const size,
const int min_size )
{
diff --git a/testsuite/check.sh b/testsuite/check.sh
index 98d539c..9a7e35b 100755
--- a/testsuite/check.sh
+++ b/testsuite/check.sh
@@ -1,7 +1,6 @@
#! /bin/sh
# check script for GNU ed - The GNU line editor
-# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012
-# Free Software Foundation, Inc.
+# Copyright (C) 2006-2015 Antonio Diaz Diaz.
#
# This script is free software; you have unlimited permission
# to copy, distribute and modify it.
@@ -12,7 +11,7 @@ objdir=`pwd`
testdir=`cd "$1" ; pwd`
ED="${objdir}"/ed
-if [ ! -x "${ED}" ] ; then
+if [ ! -f "${ED}" ] || [ ! -x "${ED}" ] ; then
echo "${ED}: cannot execute"
exit 1
fi
@@ -28,80 +27,79 @@ cd "${testdir}"
for i in *.t ; do
base=`echo "$i" | sed 's/\.t$//'`
(
- echo "#! /bin/sh"
- echo "${ED} -s <<'EOT'"
echo H
echo "r ${testdir}/${base}.d"
cat "$i"
echo "w ${base}.o"
- echo EOT
) > "${objdir}/tmp/${base}.ed"
- chmod u+x "${objdir}/tmp/${base}.ed"
done
for i in *.err ; do
base=`echo "$i" | sed 's/\.err$//'`
(
- echo "#! /bin/sh -"
- echo "${ED} -s <<'EOT'"
echo H
echo "r ${testdir}/${base}.err"
cat "$i"
echo "w ${base}.ro"
- echo EOT
) > "${objdir}/tmp/${base}.red"
- chmod u+x "${objdir}/tmp/${base}.red"
done
+cd "${objdir}"/tmp
+fail=0
+
+printf "testing ed-%s...\n" "$2"
+
# Run the .ed and .red scripts just generated
# and compare their output against the .r and .pr files, which contain
# the correct output.
-printf "testing ed-%s...\n" "$2"
-cd "${objdir}"/tmp
# Run the *.red scripts first, since these don't generate output;
# they exit with non-zero status
for i in *.red ; do
- echo "$i"
- if ./"$i" ; then
+ if "${ED}" -s < "$i" > /dev/null 2>&1 ; then
echo "*** The script $i exited abnormally ***"
+ fail=127
fi
-done > errs.ck 2>&1
+done
# Run error scripts again as pipes - these should generate output and
# exit with error (>0) status.
for i in *.red ; do
base=`echo "$i" | sed 's/\.red$//'`
- if cat ${base}.red | "${ED}" -s ; then
+ if cat ${base}.red | "${ED}" -s > /dev/null 2>&1 ; then
echo "*** The piped script $i exited abnormally ***"
+ fail=127
else
if cmp -s ${base}.ro "${testdir}"/${base}.pr ; then
true
else
echo "*** Output ${base}.ro of piped script $i is incorrect ***"
+ fail=127
fi
fi
-done > pipes.ck 2>&1
+done
-# Run the remainding scripts; they exit with zero status
+# Run the remaining scripts; they exit with zero status
for i in *.ed ; do
base=`echo "$i" | sed 's/\.ed$//'`
- if ./${base}.ed ; then
+ if "${ED}" -s < ${base}.ed > /dev/null 2>&1 ; then
if cmp -s ${base}.o "${testdir}"/${base}.r ; then
true
else
echo "*** Output ${base}.o of script $i is incorrect ***"
+ fail=127
fi
else
echo "*** The script $i exited abnormally ***"
+ fail=127
fi
-done > scripts.ck 2>&1
+done
-grep '\*\*\*' *.ck | sed 's/^[^*]*//'
-if grep '\*\*\*' *.ck > /dev/null ; then
- exit 127
-else
+if [ ${fail} = 0 ] ; then
echo "tests completed successfully."
cd "${objdir}" && rm -r tmp
+else
+ echo "tests failed."
fi
+exit ${fail}
diff --git a/testsuite/e1.r b/testsuite/e1.r
index d141049..9692412 100644
--- a/testsuite/e1.r
+++ b/testsuite/e1.r
@@ -1,5 +1,4 @@
3d
e e1.ed
-1;/H/+d
+1,2d
w e1.o
-EOT
diff --git a/testsuite/e1.t b/testsuite/e1.t
index ccbccfc..4a348d5 100644
--- a/testsuite/e1.t
+++ b/testsuite/e1.t
@@ -1,3 +1,3 @@
3d
e e1.ed
-1;/H/+d
+1,2d
diff --git a/testsuite/r3.r b/testsuite/r3.r
index d925d88..9a1567d 100644
--- a/testsuite/r3.r
+++ b/testsuite/r3.r
@@ -1,4 +1,3 @@
r r3.ed
1;/H/+d
w r3.o
-EOT