Imported Upstream version 1.12 upstream/1.12
authorDongHun Kwak <dh0128.kwak@samsung.com>
Tue, 19 Oct 2021 07:12:48 +0000 (16:12 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Tue, 19 Oct 2021 07:12:48 +0000 (16:12 +0900)
14 files changed:
ChangeLog
INSTALL
Makefile.in
NEWS
buffer.c
carg_parser.c
carg_parser.h
configure
doc/ed.1
doc/ed.info
doc/ed.texi
ed.h
main.c
main_loop.c

index bc44e75..ca1c69d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-07-04  Antonio Diaz Diaz  <antonio@gnu.org>
+
+       * Version 1.12 released.
+       * ed.texi: Removed extra spaces from some commands.
+
 2015-03-30  Antonio Diaz Diaz  <antonio@gnu.org>
 
        * Version 1.11 released.
diff --git a/INSTALL b/INSTALL
index f7bafd8..170db71 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -1,7 +1,7 @@
 Requirements
 ------------
 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
+I use gcc 4.9.1 and 4.1.2, but the code should compile with any
 standards compliant compiler.
 Gcc is available at http://gcc.gnu.org.
 
index c853e46..44d6e15 100644 (file)
@@ -19,17 +19,17 @@ objs = buffer.o carg_parser.o global.o io.o main.o main_loop.o regex.o signal.o
 all : $(progname) r$(progname)
 
 $(progname) : $(objs)
-       $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(objs)
+       $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(objs)
 
 r$(progname) : r$(progname).in
        cat $(VPATH)/r$(progname).in > $@
        chmod a+x $@
 
 main.o : main.c
-       $(CC) $(CFLAGS) $(CPPFLAGS) -DPROGVERSION=\"$(pkgversion)\" -c -o $@ $<
+       $(CC) $(CPPFLAGS) $(CFLAGS) -DPROGVERSION=\"$(pkgversion)\" -c -o $@ $<
 
 %.o : %.c
-       $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
+       $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
 
 $(objs)       : Makefile ed.h
 carg_parser.o : carg_parser.h
diff --git a/NEWS b/NEWS
index 5cb43ae..8b1428d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,11 +1,6 @@
-Changes in version 1.11:
+Changes in version 1.12:
 
-The "z" command has been fixed. ("zN" printed N + 1 lines). This bug was
-present since at least ed-0.2.
-
-The window size used by the "z" command has been documented in the
+Extra spaces have been removed from the synopses of some commands in the
 manual.
 
-The targets "install-compress", "install-strip-compress",
-"install-info-compress" and "install-man-compress" have been added to
-the Makefile.
+Minor documentation fixes.
index 8a2e268..a3e6f6e 100644 (file)
--- a/buffer.c
+++ b/buffer.c
@@ -319,8 +319,8 @@ bool join_lines( const int from, const int to, const bool isglobal )
     bp = bp->q_forw;
     }
   if( !resize_buffer( &buf, &bufsz, size + 2 ) ) return false;
-  memcpy( buf + size, "\n", 2 );
-  size += 2;
+  buf[size++] = '\n';
+  buf[size++] = 0;
   if( !delete_lines( from, to, isglobal ) ) return false;
   current_addr_ = from - 1;
   disable_interrupts();
index a453e36..8d74ea6 100644 (file)
@@ -1,28 +1,20 @@
 /*  Arg_parser - POSIX/GNU command line argument parser. (C version)
     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 2 of the License, or
-    (at your option) any later version.
+    This library is free software. Redistribution and use in source and
+    binary forms, with or without modification, are permitted provided
+    that the following conditions are met:
+
+    1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+
+    2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
 
     This library is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this library.  If not, see <http://www.gnu.org/licenses/>.
-
-    As a special exception, you may use this file as part of a free
-    software library without restriction.  Specifically, if other files
-    instantiate templates or use macros or inline functions from this
-    file, or you compile this file and link it with other files to
-    produce an executable, this file does not by itself cause the
-    resulting executable to be covered by the GNU General Public
-    License.  This exception does not however invalidate any other
-    reasons why the executable file might be covered by the GNU General
-    Public License.
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 */
 
 #include <stdlib.h>
index 34b1263..ed4d9c5 100644 (file)
@@ -1,28 +1,20 @@
 /*  Arg_parser - POSIX/GNU command line argument parser. (C version)
     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 2 of the License, or
-    (at your option) any later version.
+    This library is free software. Redistribution and use in source and
+    binary forms, with or without modification, are permitted provided
+    that the following conditions are met:
+
+    1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+
+    2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
 
     This library is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this library.  If not, see <http://www.gnu.org/licenses/>.
-
-    As a special exception, you may use this file as part of a free
-    software library without restriction.  Specifically, if other files
-    instantiate templates or use macros or inline functions from this
-    file, or you compile this file and link it with other files to
-    produce an executable, this file does not by itself cause the
-    resulting executable to be covered by the GNU General Public
-    License.  This exception does not however invalidate any other
-    reasons why the executable file might be covered by the GNU General
-    Public License.
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 */
 
 /*  Arg_parser reads the arguments in 'argv' and creates a number of
index 9f5742c..51875c9 100755 (executable)
--- a/configure
+++ b/configure
@@ -6,7 +6,7 @@
 # to copy, distribute and modify it.
 
 pkgname=ed
-pkgversion=1.11
+pkgversion=1.12
 progname=ed
 srctrigger=doc/${pkgname}.texi
 
index 1126b9d..bca3551 100644 (file)
--- a/doc/ed.1
+++ b/doc/ed.1
@@ -1,5 +1,5 @@
 .\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.46.1.
-.TH ED "1" "March 2015" "ed 1.11" "User Commands"
+.TH ED "1" "July 2015" "ed 1.12" "User Commands"
 .SH NAME
 ed \- line-oriented text editor
 .SH SYNOPSIS
index 98650bc..3b47ae7 100644 (file)
@@ -18,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.11, 30 March 2015).
+This manual is for GNU ed (version 1.12, 4 July 2015).
 
 
    GNU ed is a line-oriented text editor. It is used to create, display,
@@ -92,7 +92,7 @@ command is applied to whole lines at a time.
 followed by a single character command and possibly additional
 parameters; i.e., commands have the structure:
 
-     [ADDRESS [,ADDRESS]]COMMAND[PARAMETERS]
+     [ADDRESS[,ADDRESS]]COMMAND[PARAMETERS]
 
    The ADDRESSes indicate the line or range of lines to be affected by
 the command. If fewer addresses are given than the command accepts,
@@ -129,9 +129,8 @@ up to the task, it can be quite efficient.
 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
 <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.
+<BACKSPACE> 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
@@ -186,10 +185,9 @@ shorthand for "the whole buffer":
      *
 
    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> ("write") command:
 
-     *,w junk
+     *w junk
      137
      *
 
@@ -200,7 +198,9 @@ 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 '#'.
+followed by a <newline> character. Commands beginning with '#' are
+taken as comments and ignored. Input mode lines that begin with '#' are
+just more input.
 
      $ ed
      # The 'a' command is for appending text to the editor buffer.
@@ -349,7 +349,7 @@ prefixed with a bang.
 
 '-r'
 '--restricted'
-     Run in restricted mode. This mode disables edition of files out of
+     Run in restricted mode. This mode disables editing of files out of
      the current directory and execution of shell commands.
 
 '-s'
@@ -658,7 +658,7 @@ specified (in parenthesis).
      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
@@ -673,7 +673,7 @@ specified (in parenthesis).
      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/'
+'(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
@@ -685,14 +685,14 @@ specified (in parenthesis).
      A newline alone acts as a null command list. A single '&' repeats
      the last non-null command list.
 
+'h'
+     Prints an explanation of the last error.
+
 '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'
-     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'.
@@ -754,9 +754,9 @@ specified (in parenthesis).
      '!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
@@ -799,12 +799,12 @@ specified (in parenthesis).
      'V' are treated as a single command by undo. 'u' is its own
      inverse.
 
-'(1,$)v /RE/COMMAND-LIST'
+'(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/'
+'(1,$)V/RE/'
      This is similar to the 'G' command except that it interactively
      edits the addressed lines not matching the regular expression RE.
 
@@ -838,7 +838,7 @@ specified (in parenthesis).
      buffer is overwritten by subsequent 'y', 's', 'j', 'd', or 'c'
      commands. The current address is unchanged.
 
-'(.+1)z N'
+'(.+1)zN'
      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,
@@ -864,7 +864,7 @@ specified (in parenthesis).
 
 '(.+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.
 
 
@@ -874,7 +874,7 @@ 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
+If the terminal hangs up, 'ed' attempts to write the buffer to the file
 'ed.hup' or, if this fails, to '$HOME/ed.hup'.
 
    'ed' processes FILE arguments for backslash escapes, i.e., in a
@@ -1412,16 +1412,16 @@ permit their use in free software.
 \1f
 Tag Table:
 Node: Top\7f535
-Node: Overview\7f2193
-Node: Introduction to line editing\7f4250
-Node: Invoking ed\7f11491
-Node: Line addressing\7f13292
-Node: Regular expressions\7f16369
-Node: Commands\7f21713
-Node: Limitations\7f32993
-Node: Diagnostics\7f33634
-Node: Problems\7f34335
-Node: GNU Free Documentation License\7f34868
+Node: Overview\7f2191
+Node: Introduction to line editing\7f4247
+Node: Invoking ed\7f11466
+Node: Line addressing\7f13267
+Node: Regular expressions\7f16344
+Node: Commands\7f21688
+Node: Limitations\7f32960
+Node: Diagnostics\7f33605
+Node: Problems\7f34306
+Node: GNU Free Documentation License\7f34839
 \1f
 End Tag Table
 
index 6afc69c..5059473 100644 (file)
@@ -6,8 +6,8 @@
 @finalout
 @c %**end of header
 
-@set UPDATED 30 March 2015
-@set VERSION 1.11
+@set UPDATED 4 July 2015
+@set VERSION 1.12
 
 @dircategory Basics
 @direntry
@@ -115,7 +115,7 @@ addresses, followed by a single character command and possibly
 additional parameters; i.e., commands have the structure:
 
 @example
-[@var{address} [,@var{address}]]@var{command}[@var{parameters}]
+[@var{address}[,@var{address}]]@var{command}[@var{parameters}]
 @end example
 
 The @var{address}es indicate the line or range of lines to be affected
@@ -159,9 +159,8 @@ 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
 @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
-erase characters backwards, or @key{CONTROL}-u (i.e., hold the CONTROL
-key and type u) to erase the whole line.
+either @key{BACKSPACE} to erase characters backwards, or @key{CONTROL}-u
+(i.e., hold the CONTROL key and type u) to erase the whole line.
 
 When @command{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 @command{ed}
@@ -225,11 +224,10 @@ Mo Tu We Th Fr Sa Su
 @end example
 
 Now let's write the buffer contents to a file named @code{junk} with the
-@key{w} (@dfn{write}) command. Again, we use the @key{,} prefix to
-indicate that it's the whole buffer we want:
+@key{w} (@dfn{write}) command:
 
 @example
-*,w junk
+*w junk
 137
 *
 @end example
@@ -241,7 +239,9 @@ since unwritten changes to the buffer will be lost when we exit
 The sample sessions below illustrate some basic concepts of line editing
 with @command{ed}. We begin by creating a file, @samp{sonnet}, with some
 help from Shakespeare. As with the shell, all input to @command{ed} must
-be followed by a @key{newline} character. Comments begin with a @samp{#}.
+be followed by a @key{newline} character. Commands beginning with
+@samp{#} are taken as comments and ignored. Input mode lines that begin
+with @samp{#} are just more input.
 
 @example
 $ ed
@@ -403,7 +403,7 @@ Specifies a command prompt. This may be toggled on and off with the
 
 @item -r
 @itemx --restricted
-Run in restricted mode. This mode disables edition of files out of the
+Run in restricted mode. This mode disables editing of files out of the
 current directory and execution of shell commands.
 
 @item -s
@@ -736,7 +736,7 @@ The current address is set to the last line read.
 Sets the default filename to @var{file}. If @var{file} is not specified,
 then the default unescaped filename is printed.
 
-@item (1,$)g /@var{re}/@var{command-list}
+@item (1,$)g/@var{re}/@var{command-list}
 Global command. Applies @var{command-list} to each of the addressed
 lines matching a regular expression @var{re}. The current address is set
 to the line currently matched before @var{command-list} is executed. At
@@ -752,7 +752,7 @@ backslash (@samp{\}). Any commands are allowed, except for @samp{g},
 is invoked with the command-line option @samp{-G}, then a newline in
 @var{command-list} is equivalent to a @samp{.+1p} command.
 
-@item (1,$)G /@var{re}/
+@item (1,$)G/@var{re}/
 Interactive global command. Interactively edits the addressed lines
 matching a regular expression @var{re}. For each matching line, the line
 is printed, the current address is set, and the user is prompted to
@@ -764,14 +764,14 @@ The format of @var{command-list} is the same as that of the @samp{g}
 command. A newline alone acts as a null command list. A single @samp{&}
 repeats the last non-null command list.
 
+@item h
+Prints an explanation of the last error.
+
 @item 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.
 
-@item h
-Prints an explanation of the last error.
-
 @item (.)i
 Inserts text in the buffer before the current line. The address @samp{0}
 (zero) is valid for this command; it is equivalent to address @samp{1}.
@@ -833,9 +833,9 @@ Reads to after the addressed line the standard output of
 @samp{!command}, (see the @samp{!} command below). The default filename
 is unchanged. The current address is set to the last line read.
 
-@item (.,.)s /@var{re}/@var{replacement}/
-@itemx (.,.)s /@var{re}/@var{replacement}/g
-@itemx (.,.)s /@var{re}/@var{replacement}/@var{n}
+@item (.,.)s/@var{re}/@var{replacement}/
+@itemx (.,.)s/@var{re}/@var{replacement}/g
+@itemx (.,.)s/@var{re}/@var{replacement}/@var{n}
 Replaces text in the addressed lines matching a regular expression
 @var{re} with @var{replacement}. By default, only the first match in
 each line is replaced. If the @samp{g} (global) suffix is given, then
@@ -879,12 +879,12 @@ before the command. The global commands @samp{g}, @samp{G}, @samp{v},
 and @samp{V} are treated as a single command by undo. @samp{u} is its
 own inverse.
 
-@item (1,$)v /@var{re}/@var{command-list}
+@item (1,$)v/@var{re}/@var{command-list}
 This is similar to the @samp{g} command except that it applies
 @var{command-list} to each of the addressed lines not matching the
 regular expression @var{re}.
 
-@item (1,$)V /@var{re}/
+@item (1,$)V/@var{re}/
 This is similar to the @samp{G} command except that it interactively
 edits the addressed lines not matching the regular expression @var{re}.
 
@@ -918,7 +918,7 @@ Copies (yanks) the addressed lines to the cut buffer. The cut buffer is
 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}
+@item (.+1)z@var{n}
 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
@@ -945,7 +945,7 @@ Prints the line number of the addressed line.
 
 @item (.+1)@key{newline}
 An address alone prints the addressed line. A @key{newline} alone is
-equivalent to @samp{+1p}. the current address is set to the address of
+equivalent to @samp{+1p}. The current address is set to the address of
 the printed line.
 
 @end table
@@ -955,7 +955,7 @@ the printed line.
 @chapter Limitations
 
 If the terminal hangs up, @command{ed} attempts to write the buffer to
-file @file{ed.hup} or, if this fails, to @file{$HOME/ed.hup}.
+the file @file{ed.hup} or, if this fails, to @file{$HOME/ed.hup}.
 
 @command{ed} processes @var{file} arguments for backslash escapes, i.e.,
 in a filename, any character preceded by a backslash (@samp{\}) is
diff --git a/ed.h b/ed.h
index ab94047..43cd355 100644 (file)
--- a/ed.h
+++ b/ed.h
@@ -37,7 +37,7 @@ typedef struct line           /* Line node */
   struct line * q_forw;
   struct line * q_back;
   long pos;                    /* position of text in scratch buffer */
-  int len;                     /* length of line */
+  int len;                     /* length of line ('\n' is not stored) */
   }
 line_t;
 
diff --git a/main.c b/main.c
index de223c0..ff7e4a2 100644 (file)
--- a/main.c
+++ b/main.c
@@ -97,8 +97,7 @@ void show_strerror( const char * const filename, const int errcode )
   {
   if( !scripted_ )
     {
-    if( filename && filename[0] != 0 )
-      fprintf( stderr, "%s: ", filename );
+    if( filename && filename[0] ) fprintf( stderr, "%s: ", filename );
     fprintf( stderr, "%s\n", strerror( errcode ) );
     }
   }
@@ -110,7 +109,7 @@ static void show_error( const char * const msg, const int errcode, const bool he
     {
     fprintf( stderr, "%s: %s", program_name, msg );
     if( errcode > 0 ) fprintf( stderr, ": %s", strerror( errcode ) );
-    fprintf( stderr, "\n" );
+    fputc( '\n', stderr );
     }
   if( help )
     fprintf( stderr, "Try '%s --help' for more information.\n",
index 2081b38..0d118cc 100644 (file)
@@ -614,7 +614,7 @@ static int exec_command( const char ** const ibufpp, const int prev_status,
               if( !fnp ) return ERR;
               if( system( fnp + 1 ) < 0 )
                 { set_error_msg( "Can't create shell process" ); return ERR; }
-              if( !scripted() ) printf( "!\n" );
+              if( !scripted() ) fputs( "!\n", stdout );
               break;
     case '\n': first_addr = 1;
               if( !check_addr_range( first_addr, current_addr() +
@@ -706,7 +706,7 @@ int main_loop( const bool loose )
     fflush( stdout );
     if( status < 0 && verbose )
       { fprintf( stderr, "%s\n", errmsg ); fflush( stderr ); }
-    if( prompt_on ) { printf( "%s", prompt_str ); fflush( stdout ); }
+    if( prompt_on ) { fputs( prompt_str, stdout ); fflush( stdout ); }
     ibufp = get_tty_line( &len );
     if( !ibufp ) return err_status;
     if( !len )