Applied patch from Mark Ferrell <mferrell@mvista.com> to fix sed '1,$p' where
authorMark Whitley <markw@lineo.com>
Thu, 10 Aug 2000 00:09:47 +0000 (00:09 -0000)
committerMark Whitley <markw@lineo.com>
Thu, 10 Aug 2000 00:09:47 +0000 (00:09 -0000)
sed was only printing the first line and then exiting.

editors/sed.c
sed.c

index 665471913d72f03fdedb2b1e664d1eab2024286d..60b1e8d2e5efe0d303c25646576e3e2e81361433 100644 (file)
@@ -639,8 +639,8 @@ static void process_file(FILE *file)
                        }
 
                        /* are we acting on a range of line numbers? */
-                       else if (sed_cmds[i].beg_line > 0 && sed_cmds[i].end_line > 0) {
-                               if (linenum >= sed_cmds[i].beg_line && linenum <= sed_cmds[i].end_line)
+                       else if (sed_cmds[i].beg_line > 0 && sed_cmds[i].end_line != 0) {
+                               if (linenum >= sed_cmds[i].beg_line && (sed_cmds[i].end_line == -1 || linenum <= sed_cmds[i].end_line))
                                        line_altered += do_sed_command(&sed_cmds[i], line);
                        }
 
diff --git a/sed.c b/sed.c
index 665471913d72f03fdedb2b1e664d1eab2024286d..60b1e8d2e5efe0d303c25646576e3e2e81361433 100644 (file)
--- a/sed.c
+++ b/sed.c
@@ -639,8 +639,8 @@ static void process_file(FILE *file)
                        }
 
                        /* are we acting on a range of line numbers? */
-                       else if (sed_cmds[i].beg_line > 0 && sed_cmds[i].end_line > 0) {
-                               if (linenum >= sed_cmds[i].beg_line && linenum <= sed_cmds[i].end_line)
+                       else if (sed_cmds[i].beg_line > 0 && sed_cmds[i].end_line != 0) {
+                               if (linenum >= sed_cmds[i].beg_line && (sed_cmds[i].end_line == -1 || linenum <= sed_cmds[i].end_line))
                                        line_altered += do_sed_command(&sed_cmds[i], line);
                        }