Article View: gnu.utils.bug
Article #942sed-1.09 bug
From: Eric Backus
Date: Fri, 25 Sep 1992 21:56
Date: Fri, 25 Sep 1992 21:56
76 lines
2631 bytes
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
Technical Details
Message-ID:
<9209252157.AA17968@labejb.lsid.hp.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!noc.near.net!news.Brown.EDU!qt.cs.utexas.edu!yale.edu!spool.mu.edu!caen!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!lsid.hp.com!ericbShow Full Headers
Complete Article Headers
Newsgroups: gnu.utils.bug Path: arc1-ca.pugleaf.net!sparky!uunet!noc.near.net!news.Brown.EDU!qt.cs.utexas.edu!yale.edu!spool.mu.edu!caen!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!lsid.hp.com!ericb From: ericb@lsid.hp.com (Eric Backus) Subject: sed-1.09 bug Message-ID: <9209252157.AA17968@labejb.lsid.hp.com> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Fri, 25 Sep 1992 21:56:58 GMT Approved: bug-gnu-utils@prep.ai.mit.edu Lines: 77