🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Eric Backus Fri, 25 Sep 1992 21:56
sed-1.09 bug
#942
Author: Eric Backus
Date: Fri, 25 Sep 1992 21:56
76 lines
2631 bytes
I think I've found a bug in GNU sed-1.09.  Here is how to reproduce
the bug:


$ echo 1 > tester
$ echo 2 >> tester
$ echo 3 >> tester
$ gsed --version
GNU sed version 1.09
Usage: gsed [-nV] [--quiet] [--silent] [--version] [-e script]
        [-f script-file] [--expression=script] [--file=script-file] [file...]
$ gsed -e "1,1s/^/BEGIN /" tester
BEGIN 1
BEGIN 2
3
$ /bin/sed -e "1,1s/^/BEGIN /" tester
BEGIN 1
2
3
$ uname -a
HP-UX labejb B.08.00 B 9000/350 08000902bacf



Note that the sed script specified "starting at line number 1, and
ending at line number 1, substitute the string 'BEGIN ' at the start
of the line".  However, what happened is GNU sed did the substitution
on the first two lines.  This behavior is unexpected and is different
from what the sed on HP-UX 8.0 does.

The following patch appears to fix the problem:

*** sed.c.orig	Fri Sep 25 13:18:49 1992
--- sed.c	Fri Sep 25 14:33:51 1992
***************
*** 504,511 ****
  		}
  		if (   cur_cmd->a1.addr_type == ADDR_NUM
  		    && cur_cmd->a2.addr_type == ADDR_NUM
! 		    && cur_cmd->a2.addr_number <= cur_cmd->a1.addr_number)
! 		  cur_cmd->a2.addr_number = cur_cmd->a1.addr_number+1;
  
  		ch=inchar();
  		if(ch==EOF)
--- 504,511 ----
  		}
  		if (   cur_cmd->a1.addr_type == ADDR_NUM
  		    && cur_cmd->a2.addr_type == ADDR_NUM
! 		    && cur_cmd->a2.addr_number < cur_cmd->a1.addr_number)
! 		  cur_cmd->a2.addr_number = cur_cmd->a1.addr_number;
  
  		ch=inchar();
  		if(ch==EOF)
***************
*** 1062,1068 ****
  		} else if(match_address(&(cur_cmd->a1))) {
  			addr_matched=1;
  			if(cur_cmd->a2.addr_type!=ADDR_NULL)
! 				cur_cmd->aflags|=A1_MATCHED_BIT;
  		}
  		if(cur_cmd->aflags&ADDR_BANG_BIT)
  			addr_matched= !addr_matched;
--- 1062,1069 ----
  		} else if(match_address(&(cur_cmd->a1))) {
  			addr_matched=1;
  			if(cur_cmd->a2.addr_type!=ADDR_NULL)
! 				if(!match_address(&(cur_cmd->a2)))
! 					cur_cmd->aflags|=A1_MATCHED_BIT;
  		}
  		if(cur_cmd->aflags&ADDR_BANG_BIT)
  			addr_matched= !addr_matched;

--
				Eric Backus
				ericb%hplsla@hplabs.hp.com
				(206) 335-2495
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads